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

Commit

Permalink
fix switches for alternative shells on Windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gucong3000 authored and isaacs committed Jul 17, 2019
1 parent 3aaf954 commit 051cf20
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Expand Up @@ -288,8 +288,11 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
sh = customShell
} else if (isWindows) {
sh = process.env.comspec || 'cmd'
shFlag = '/d /s /c'
conf.windowsVerbatimArguments = true
// '/d /s /c' is used only for cmd.exe.
if (/^(?:.*\\)?cmd(?:\.exe)?$/i.test(sh)) {
shFlag = '/d /s /c'
conf.windowsVerbatimArguments = true
}
}

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

0 comments on commit 051cf20

Please sign in to comment.