From 2979c46c309a3b3d3a1afbdd833054b1a2d54dc5 Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Tue, 27 Feb 2018 10:56:16 +0000 Subject: [PATCH] fix: windows exec resolution Fixes #1251 --- lib/monitor/run.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/monitor/run.js b/lib/monitor/run.js index 930b3099..f7505565 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -48,14 +48,26 @@ function run(options) { stdio: stdio, } + var executable = cmd.executable; + if (utils.isWindows) { + // if the exec includes a forward slash, reverse it for windows compat + // but *only* apply to the first command, and none of the arguments. + // ref #1251 and #1236 + if (executable.indexOf('/') !== -1) { + executable = executable.split(' ').map((e, i) => { + if (i === 0) { + return path.normalize(e); + } + return e; + }).join(' '); + } // taken from npm's cli: https://git.io/vNFD4 sh = process.env.comspec || 'cmd'; shFlag = '/d /s /c'; spawnOptions.windowsVerbatimArguments = true; } - var executable = cmd.executable; var args = runCmd ? utils.stringify(executable, cmd.args) : ':'; var spawnArgs = [sh, [shFlag, args], spawnOptions];