Skip to content

Commit a5e6525

Browse files
committed
fix(cli): use platform-specific PATH separator in npm tests
Fix npm ENOENT errors on Windows by using the correct PATH separator. Windows uses semicolon (;) while Unix uses colon (:). This caused npm to not be found in PATH on Windows CI, resulting in "spawn npm ENOENT" errors in socket-npm-integration.test.mts.
1 parent da2a26a commit a5e6525

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/cli/src/commands/npm/socket-npm-integration.test.mts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ if (!npmDirs.length) {
3939

4040
describe(`Socket npm wrapper for ${npmDir}`, () => {
4141
const useDebug = isDebug('stdio')
42+
// Use platform-specific path separator for PATH construction.
43+
const pathSep = process.platform === 'win32' ? ';' : ':'
4244

4345
it(
4446
'should intercept npm commands and show Socket output',
@@ -62,7 +64,7 @@ if (!npmDirs.length) {
6264
cwd: npmPath,
6365
env: {
6466
...process.env,
65-
PATH: `${npmBinPath}:${ENV.PATH}`,
67+
PATH: `${npmBinPath}${pathSep}${ENV.PATH}`,
6668
},
6769
},
6870
)
@@ -105,7 +107,7 @@ if (!npmDirs.length) {
105107
cwd: path.join(npmFixturesPath, 'lacking-typosquat'),
106108
env: {
107109
...process.env,
108-
PATH: `${npmBinPath}:${ENV.PATH}`,
110+
PATH: `${npmBinPath}${pathSep}${ENV.PATH}`,
109111
},
110112
},
111113
)

0 commit comments

Comments
 (0)