Skip to content

Commit 9d9f7fe

Browse files
committed
Quick fix for Socket Optimize and npm ci
1 parent f08548b commit 9d9f7fe

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/commands/optimize.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,13 +895,32 @@ export const optimize: CliSubcommand = {
895895
try {
896896
if (isNpm) {
897897
const wrapperPath = path.join(distPath, 'npm-cli.js')
898-
await spawn(process.execPath, [wrapperPath, 'install', '--silent'], {
898+
const npmSpawnOptions: Parameters<typeof spawn>[2] = {
899899
stdio: 'ignore',
900900
env: {
901901
...process.env,
902902
[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: '1'
903903
}
904-
})
904+
}
905+
await spawn(
906+
process.execPath,
907+
[wrapperPath, 'install', '--silent'],
908+
npmSpawnOptions
909+
)
910+
// TODO: This is a temporary workaround for an `npm ci` bug where it
911+
// will error out after Socket Optimize generates a lock file. More
912+
// investigation is needed.
913+
await spawn(
914+
process.execPath,
915+
[
916+
wrapperPath,
917+
'install',
918+
'--silent',
919+
'--ignore-scripts',
920+
'--package-lock-only'
921+
],
922+
npmSpawnOptions
923+
)
905924
} else {
906925
// All package managers support the "install" command.
907926
await spawn(agentExecPath, ['install'], { stdio: 'ignore' })

0 commit comments

Comments
 (0)