Skip to content

Commit 58da157

Browse files
RYGRITdanielroe
andauthored
fix(cli): cli windows compat (#942)
Co-authored-by: Daniel Roe <daniel@roe.dev>
1 parent ec1f032 commit 58da157

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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)