From af829ef37f36ec5dcc147247c65077639cf75aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=BA?= Date: Fri, 9 Nov 2018 17:33:09 +0800 Subject: [PATCH 1/2] 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. --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4eb8325..224f03a 100644 --- a/index.js +++ b/index.js @@ -282,8 +282,11 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) { sh = customShell } else if (process.platform === 'win32') { 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(file)) { + shFlag = '/d /s /c' + conf.windowsVerbatimArguments = true + } } opts.log.verbose('lifecycle', logid(pkg, stage), 'PATH:', env[PATH]) From 2ebd89f28fdbe89a57178abd387c35ad23023e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=BA?= Date: Fri, 9 Nov 2018 17:41:04 +0800 Subject: [PATCH 2/2] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 224f03a..5a0eb05 100644 --- a/index.js +++ b/index.js @@ -283,7 +283,7 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) { } else if (process.platform === 'win32') { sh = process.env.comspec || 'cmd' // '/d /s /c' is used only for cmd.exe. - if (/^(?:.*\\)?cmd(?:\.exe)?$/i.test(file)) { + if (/^(?:.*\\)?cmd(?:\.exe)?$/i.test(sh)) { shFlag = '/d /s /c' conf.windowsVerbatimArguments = true }