@auroraflow/code 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -211,10 +211,11 @@ function tomlString(value) {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
async function spawnAndExit(command, args, env) {
|
|
214
|
-
const
|
|
214
|
+
const spec = windowsCommandSpec(command, args);
|
|
215
|
+
const child = spawn(spec.command, spec.args, {
|
|
215
216
|
stdio: "inherit",
|
|
216
217
|
env,
|
|
217
|
-
shell:
|
|
218
|
+
shell: spec.shell
|
|
218
219
|
});
|
|
219
220
|
child.on("error", error => {
|
|
220
221
|
console.error(`Failed to start ${command}: ${error.message}`);
|
|
@@ -225,11 +226,12 @@ async function spawnAndExit(command, args, env) {
|
|
|
225
226
|
|
|
226
227
|
function spawnAndWait(command, args, env) {
|
|
227
228
|
return new Promise((resolve, reject) => {
|
|
228
|
-
const
|
|
229
|
+
const spec = windowsCommandSpec(command, args);
|
|
230
|
+
const child = spawn(spec.command, spec.args, {
|
|
229
231
|
cwd: packageRoot,
|
|
230
232
|
stdio: "inherit",
|
|
231
233
|
env,
|
|
232
|
-
shell:
|
|
234
|
+
shell: spec.shell
|
|
233
235
|
});
|
|
234
236
|
child.on("error", reject);
|
|
235
237
|
child.on("exit", code => {
|
|
@@ -240,8 +242,34 @@ function spawnAndWait(command, args, env) {
|
|
|
240
242
|
}
|
|
241
243
|
|
|
242
244
|
function spawnSyncCompat(command, args) {
|
|
243
|
-
|
|
245
|
+
const spec = windowsCommandSpec(command, args);
|
|
246
|
+
return spawnSync(spec.command, spec.args, {
|
|
244
247
|
encoding: "utf8",
|
|
245
|
-
shell:
|
|
248
|
+
shell: spec.shell
|
|
246
249
|
});
|
|
247
250
|
}
|
|
251
|
+
|
|
252
|
+
function windowsCommandSpec(command, args) {
|
|
253
|
+
if (process.platform !== "win32" || !command.toLowerCase().endsWith(".cmd")) {
|
|
254
|
+
return { command, args, shell: false };
|
|
255
|
+
}
|
|
256
|
+
// Windows npm global bins are .cmd shims, commonly under "C:\Program Files".
|
|
257
|
+
// Running that path through shell=true without quoting makes cmd.exe split at
|
|
258
|
+
// the space and try to execute "C:\Program". Invoke cmd.exe explicitly with
|
|
259
|
+
// one quoted command line so paths with spaces survive.
|
|
260
|
+
return {
|
|
261
|
+
command: process.env.ComSpec || "cmd.exe",
|
|
262
|
+
args: ["/d", "/s", "/c", windowsCmdLine([command, ...args])],
|
|
263
|
+
shell: false
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function windowsCmdLine(parts) {
|
|
268
|
+
return parts.map(windowsCmdQuote).join(" ");
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function windowsCmdQuote(value) {
|
|
272
|
+
const text = String(value);
|
|
273
|
+
if (/^[A-Za-z0-9_./:=+-]+$/.test(text)) return text;
|
|
274
|
+
return `"${text.replace(/"/g, '""')}"`;
|
|
275
|
+
}
|