Skip to content

Commit 4b45b56

Browse files
committed
fix(cli): enable shell for npm on windows
1 parent bf0c8f7 commit 4b45b56

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cli/src/npm-client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,12 @@ async function execNpm(
124124

125125
try {
126126
// Use execFile instead of exec to avoid shell injection vulnerabilities
127-
// execFile does not spawn a shell, so metacharacters are passed literally
127+
// On Windows, shell: true is required to execute .cmd files (like npm.cmd)
128+
// On Unix, we keep it false for better security and performance
128129
const { stdout, stderr } = await execFileAsync('npm', npmArgs, {
129130
timeout: 60000,
130131
env: { ...process.env, FORCE_COLOR: '0' },
132+
shell: process.platform === 'win32',
131133
})
132134

133135
if (!options.silent) {
@@ -386,6 +388,7 @@ export async function packageInit(
386388
timeout: 60000,
387389
cwd: tempDir,
388390
env: { ...process.env, FORCE_COLOR: '0' },
391+
shell: process.platform === 'win32',
389392
})
390393

391394
logSuccess(`Published ${name}@0.0.0`)

0 commit comments

Comments
 (0)