Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 051cf20

Browse files
gucong3000isaacs
authored andcommitted
fix switches for alternative shells on Windows
On Windows, normalizeSpawnArguments set "/d /s /c" for any shells. It cause exec and other methods are limited to cmd.exe as a shell. Powershell and git-bash are often used instead of cmd.exe, and they can recieve "-c" switch like unix shells. So normalizeSpawnArguments is changed to set "/d /s /c" for cmd.exe, and "-c" for others. PR-URL: #26 Close: #26 Reviewed-by: @isaacs Credit: @gucong3000
1 parent 3aaf954 commit 051cf20

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,11 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
288288
sh = customShell
289289
} else if (isWindows) {
290290
sh = process.env.comspec || 'cmd'
291-
shFlag = '/d /s /c'
292-
conf.windowsVerbatimArguments = true
291+
// '/d /s /c' is used only for cmd.exe.
292+
if (/^(?:.*\\)?cmd(?:\.exe)?$/i.test(sh)) {
293+
shFlag = '/d /s /c'
294+
conf.windowsVerbatimArguments = true
295+
}
293296
}
294297

295298
opts.log.verbose('lifecycle', logid(pkg, stage), 'PATH:', env[PATH])

0 commit comments

Comments
 (0)