extract expression into function

This commit is contained in:
Wesley Wigham 2016-06-24 11:01:16 -07:00
parent e5ddcfed07
commit 034c41822e
No known key found for this signature in database
GPG Key ID: D59F87F60C5400C9

View File

@ -69,12 +69,15 @@ function exec(cmd: string, args: string[], complete: () => void = (() => {}), er
console.log(`${cmd} ${args.join(" ")}`);
// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
const subshellFlag = isWin ? "/c" : "-c";
const command = isWin ? [cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd, ...args] : [`${cmd} ${args.join(" ")}`];
const command = isWin ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`];
const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true } as any);
ex.on("exit", (code) => code === 0 ? complete() : error(/*e*/ undefined, code));
ex.on("error", error);
}
function possiblyQuote(cmd: string) {
return cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd;
}
let useDebugMode = true;
let host = cmdLineOptions["host"];