@@ -10,8 +10,12 @@ import { installLinks } from './link'
1010import constants from '../constants'
1111
1212const {
13+ NPM ,
14+ SOCKET_CLI_LEGACY_PACKAGE_NAME ,
15+ SOCKET_CLI_PACKAGE_NAME ,
1316 SOCKET_CLI_SAFE_WRAPPER ,
1417 SOCKET_CLI_SENTRY_BUILD ,
18+ SOCKET_CLI_SENTRY_PACKAGE_NAME ,
1519 SOCKET_IPC_HANDSHAKE
1620} = constants
1721
@@ -21,9 +25,18 @@ export default async function shadowBin(
2125) {
2226 process . exitCode = 1
2327 const terminatorPos = args . indexOf ( '--' )
24- const binArgs = (
25- terminatorPos === - 1 ? args : args . slice ( 0 , terminatorPos )
26- ) . filter ( a => ! isProgressFlag ( a ) )
28+ const skipSocketCliUpgrade = binName === NPM
29+ args . length === 3 &&
30+ args [ 0 ] === 'install' &&
31+ args [ 1 ] === '-g' &&
32+ ( args [ 2 ] === SOCKET_CLI_PACKAGE_NAME ||
33+ args [ 2 ] === SOCKET_CLI_LEGACY_PACKAGE_NAME ||
34+ args [ 2 ] === SOCKET_CLI_SENTRY_PACKAGE_NAME )
35+
36+ let binArgs = terminatorPos === - 1 ? args : args . slice ( 0 , terminatorPos )
37+ if ( ! skipSocketCliUpgrade ) {
38+ binArgs = binArgs . filter ( a => ! isProgressFlag ( a ) )
39+ }
2740 const otherArgs = terminatorPos === - 1 ? [ ] : args . slice ( terminatorPos )
2841 const spawnPromise = spawn (
2942 // Lazily access constants.execPath.
@@ -46,9 +59,13 @@ export default async function shadowBin(
4659 await installLinks ( constants . shadowBinPath , binName ) ,
4760 // Add `--no-progress` and `--quiet` flags to fix input being swallowed by
4861 // the spinner when running the command with recent versions of npm.
49- '--no-progress' ,
62+ ... ( skipSocketCliUpgrade ? [ ] : [ '--no-progress' ] ) ,
5063 // Add the '--quiet' flag if a loglevel flag is not provided.
51- ...( binArgs . some ( isLoglevelFlag ) ? [ ] : [ '--quiet' ] ) ,
64+ ...( binArgs . some ( isLoglevelFlag )
65+ ? [ ]
66+ : skipSocketCliUpgrade
67+ ? [ '--loglevel' , 'error' ]
68+ : [ '--quiet' ] ) ,
5269 ...binArgs ,
5370 ...otherArgs
5471 ] ,
0 commit comments