Skip to content

Commit

Permalink
spawnYarn: args must go after yarn options (#1362).
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Jan 25, 2024
1 parent 94a9128 commit bde6878
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/package-managers/bun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ async function spawnBun(
programError(npmOptions, 'Bun not yet supported on Windows')
}

args = Array.isArray(args) ? args : [args]

const fullArgs = [
...args,
...(npmOptions.prefix ? `--prefix=${npmOptions.prefix}` : []),
...(npmOptions.location === 'global' ? ['--global'] : []),
...(Array.isArray(args) ? args : [args]),
]

return spawn('bun', fullArgs, spawnOptions)
Expand Down
11 changes: 6 additions & 5 deletions src/package-managers/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,17 +549,18 @@ async function spawnNpm(
const cmd = process.platform === 'win32' ? 'npm.cmd' : 'npm'
args = Array.isArray(args) ? args : [args]

const fullArgs = args.concat(
npmOptions.location
const fullArgs = [
...(npmOptions.location
? (await isGlobalDeprecated())
? `--location=${npmOptions.location}`
: npmOptions.location === 'global'
? '--global'

This comment has been minimized.

Copy link
@yhx-12243

yhx-12243 Jan 26, 2024

This causes a destructuring error (causes string destructuring) (#1365).

: ''
: [],
npmOptions.prefix ? `--prefix=${npmOptions.prefix}` : [],
: []),
...(npmOptions.prefix ? `--prefix=${npmOptions.prefix}` : []),
'--json',
)
...(Array.isArray(args) ? args : [args]),
]
return spawn(cmd, fullArgs, spawnOptions)
}

Expand Down
4 changes: 3 additions & 1 deletion src/package-managers/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ async function spawnYarn(

const fullArgs = [
...(yarnOptions.location === 'global' ? 'global' : []),
...(Array.isArray(args) ? args : [args]),
'--depth=0',
...(yarnOptions.prefix ? `--prefix=${yarnOptions.prefix}` : []),
'--json',
'--no-progress',
// args must go after yarn options, otherwise they are passed through to npm scripts
// https://github.com/raineorshine/npm-check-updates/issues/1362
...(Array.isArray(args) ? args : [args]),
]

return spawn(cmd, fullArgs, spawnOptions)
Expand Down

0 comments on commit bde6878

Please sign in to comment.