File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import process from 'node:process'
22
3+ import { isDebug } from '@socketsecurity/registry/lib/debug'
34import {
45 isLoglevelFlag ,
56 isProgressFlag
@@ -21,11 +22,14 @@ export default async function shadowBin(
2122 level = 1
2223) {
2324 process . exitCode = 1
25+ const useDebug = isDebug ( )
2426 const terminatorPos = args . indexOf ( '--' )
2527 const binArgs = (
2628 terminatorPos === - 1 ? args : args . slice ( 0 , terminatorPos )
2729 ) . filter ( a => ! isProgressFlag ( a ) )
2830 const otherArgs = terminatorPos === - 1 ? [ ] : args . slice ( terminatorPos )
31+ const isSilent = ! useDebug && ! binArgs . some ( isLoglevelFlag )
32+ const logLevelArgs = isSilent ? [ '--loglevel' , 'silent' ] : [ ]
2933 const spawnPromise = spawn (
3034 // Lazily access constants.execPath.
3135 constants . execPath ,
@@ -49,8 +53,9 @@ export default async function shadowBin(
4953 await installLinks ( constants . shadowBinPath , binName ) ,
5054 // Add `--no-progress` to fix input being swallowed by the npm spinner.
5155 '--no-progress' ,
52- // Add the '--loglevel=silent' flag if a loglevel flag is not provided.
53- ...( binArgs . some ( isLoglevelFlag ) ? [ ] : [ '--loglevel' , 'silent' ] ) ,
56+ // Add '--loglevel=silent' if a loglevel flag is not provided and the
57+ // SOCKET_CLI_DEBUG environment variable is not truthy.
58+ ...logLevelArgs ,
5459 ...binArgs ,
5560 ...otherArgs
5661 ] ,
Original file line number Diff line number Diff line change @@ -37,11 +37,11 @@ export function safeNpmInstall(options?: SafeNpmInstallOptions) {
3737 const useIpc = isObject ( ipc )
3838 const useDebug = isDebug ( )
3939 const terminatorPos = args . indexOf ( '--' )
40- const npmArgs = (
40+ const binArgs = (
4141 terminatorPos === - 1 ? args : args . slice ( 0 , terminatorPos )
4242 ) . filter ( a => ! isAuditFlag ( a ) && ! isFundFlag ( a ) && ! isProgressFlag ( a ) )
4343 const otherArgs = terminatorPos === - 1 ? [ ] : args . slice ( terminatorPos )
44- const isSilent = ! useDebug && ! npmArgs . some ( isLoglevelFlag )
44+ const isSilent = ! useDebug && ! binArgs . some ( isLoglevelFlag )
4545 const logLevelArgs = isSilent ? [ '--loglevel' , 'silent' ] : [ ]
4646 const spawnPromise = spawn (
4747 // Lazily access constants.execPath.
@@ -72,7 +72,7 @@ export function safeNpmInstall(options?: SafeNpmInstallOptions) {
7272 // Add '--loglevel=silent' if a loglevel flag is not provided and the
7373 // SOCKET_CLI_DEBUG environment variable is not truthy.
7474 ...logLevelArgs ,
75- ...npmArgs ,
75+ ...binArgs ,
7676 ...otherArgs
7777 ] ,
7878 {
You can’t perform that action at this time.
0 commit comments