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'
33import spawn from '@npmcli/promise-spawn'
44import { getManifestData } from '@socketsecurity/registry'
55import meow from 'meow'
6+ import ora from 'ora'
67
78import { printFlagList } from '../utils/formatting'
89import { writeFileUtf8 } from '../utils/fs'
@@ -363,21 +364,29 @@ export const optimize: CliSubcommand = {
363364 aoState
364365 )
365366 }
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- }
377367 }
378368 const { size : count } = aoState . packageNames
379369 if ( count ) {
380370 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+ }
381390 } else {
382391 console . log ( 'Congratulations! Already Socket.dev optimized 🎉' )
383392 }
You can’t perform that action at this time.
0 commit comments