File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import path from 'node:path'
3
3
import spawn from '@npmcli/promise-spawn'
4
4
import { getManifestData } from '@socketsecurity/registry'
5
5
import meow from 'meow'
6
+ import ora from 'ora'
6
7
7
8
import { printFlagList } from '../utils/formatting'
8
9
import { writeFileUtf8 } from '../utils/fs'
@@ -363,21 +364,29 @@ export const optimize: CliSubcommand = {
363
364
aoState
364
365
)
365
366
}
366
- if ( agent === 'npm' ) {
367
- const wrapperPath = path . join ( distPath , 'npm-cli.js' )
368
- await spawn ( process . execPath , [ wrapperPath , ...argv ] , {
369
- stdio : 'inherit' ,
370
- env : ( < unknown > {
371
- __proto__ : null ,
372
- ...process . env ,
373
- UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE : '1'
374
- } ) as NodeJS . ProcessEnv
375
- } )
376
- }
377
367
}
378
368
const { size : count } = aoState . packageNames
379
369
if ( count ) {
380
370
console . log ( `Added ${ count } Socket.dev optimized overrides 🚀` )
371
+ if ( agent === 'npm' ) {
372
+ const spinner = ora ( 'Updating package-lock.json...' ) . start ( )
373
+ const wrapperPath = path . join ( distPath , 'npm-cli.js' )
374
+ try {
375
+ await spawn ( process . execPath , [ wrapperPath , 'install' ] , {
376
+ stdio : 'pipe' ,
377
+ env : ( < unknown > {
378
+ __proto__ : null ,
379
+ ...process . env ,
380
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE : '1'
381
+ } ) as NodeJS . ProcessEnv
382
+ } )
383
+ } catch {
384
+ console . log (
385
+ '✘ socket npm install: Failed to update package-lock.json'
386
+ )
387
+ }
388
+ spinner . stop ( )
389
+ }
381
390
} else {
382
391
console . log ( 'Congratulations! Already Socket.dev optimized 🎉' )
383
392
}
You can’t perform that action at this time.
0 commit comments