Skip to content

Commit acf2f93

Browse files
committed
Cleanup shadow bin args/flags
1 parent db2034d commit acf2f93

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

src/shadow/shadow-bin.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@ export default async function shadowBin(
2424
path.join(constants.distPath, 'npm-injection.js'),
2525
// Lazily access constants.shadowBinPath.
2626
await installLinks(constants.shadowBinPath, binName),
27-
...binArgs,
28-
// Add the `--quiet` and `--no-progress` flags to fix input being swallowed
29-
// by the spinner when running the command with recent versions of npm.
30-
...(binName === NPM &&
31-
binArgs.includes('install') &&
32-
!binArgs.includes('--no-progress') &&
33-
!binArgs.includes('--quiet')
34-
? ['--no-progress', '--quiet']
35-
: [])
27+
...(binName === NPM && binArgs.includes('install')
28+
? [
29+
// Add the `--quiet` and `--no-progress` flags to fix input being swallowed
30+
// by the spinner when running the command with recent versions of npm.
31+
...binArgs.filter(a => a !== '--progress' && a !== '--no-progress'),
32+
'--no-progress',
33+
...(binArgs.includes('-q') ||
34+
binArgs.includes('--quiet') ||
35+
binArgs.includes('-s') ||
36+
binArgs.includes('--silent')
37+
? []
38+
: ['--quiet'])
39+
]
40+
: binArgs)
3641
],
3742
{
3843
signal: abortSignal,

src/utils/shadow-npm.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,20 @@ type ShadowNpmInstallOptions = SpawnOption & {
1919
}
2020

2121
export function shadowNpmInstall(opts?: ShadowNpmInstallOptions) {
22-
const { flags = [], ipc, ...spawnOptions } = { __proto__: null, ...opts }
22+
const {
23+
flags: flags_ = [],
24+
ipc,
25+
...spawnOptions
26+
} = { __proto__: null, ...opts }
27+
const flags = flags_.filter(
28+
f =>
29+
f !== '--audit' &&
30+
f !== '--fund' &&
31+
f !== '--progress' &&
32+
f !== '--no-audit' &&
33+
f !== '--no-fund' &&
34+
f !== '--no-progress'
35+
)
2336
const useIpc = isObject(ipc)
2437
const useDebug = isDebug()
2538
const spawnPromise = spawn(
@@ -55,15 +68,7 @@ export function shadowNpmInstall(opts?: ShadowNpmInstallOptions) {
5568
)
5669
? []
5770
: ['--silent']),
58-
...flags.filter(
59-
f =>
60-
f !== '--audit' &&
61-
f !== '--fund' &&
62-
f !== '--progress' &&
63-
f !== '--no-audit' &&
64-
f !== '--no-fund' &&
65-
f !== '--no-progress'
66-
)
71+
...flags
6772
],
6873
{
6974
signal: abortSignal,

0 commit comments

Comments
 (0)