Skip to content

Commit 0b4b372

Browse files
authored
Merge pull request #9340 from Microsoft/gulp-allow-space-in-exec
Gulp: Allow space in exec cmds
2 parents a0a9666 + 034c418 commit 0b4b372

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Gulpfile.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@ function exec(cmd: string, args: string[], complete: () => void = (() => {}), er
6969
console.log(`${cmd} ${args.join(" ")}`);
7070
// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
7171
const subshellFlag = isWin ? "/c" : "-c";
72-
const command = isWin ? [cmd, ...args] : [`${cmd} ${args.join(" ")}`];
72+
const command = isWin ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`];
7373
const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true } as any);
7474
ex.on("exit", (code) => code === 0 ? complete() : error(/*e*/ undefined, code));
7575
ex.on("error", error);
7676
}
7777

78+
function possiblyQuote(cmd: string) {
79+
return cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd;
80+
}
7881

7982
let useDebugMode = true;
8083
let host = cmdLineOptions["host"];

0 commit comments

Comments
 (0)