@rzl-zone/build-tools 0.0.9 → 0.0.11
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/dist/.references/index.d.cts +1 -1
- package/dist/.references/index.d.ts +1 -1
- package/dist/bundler/rolldown.cjs +2 -2
- package/dist/bundler/rolldown.d.cts +2 -2
- package/dist/bundler/rolldown.d.ts +2 -2
- package/dist/bundler/rolldown.js +1 -1
- package/dist/bundler/tsdown.cjs +3 -3
- package/dist/bundler/tsdown.d.cts +2 -2
- package/dist/bundler/tsdown.d.ts +2 -2
- package/dist/bundler/tsdown.js +3 -3
- package/dist/bundler/utils.cjs +2 -2
- package/dist/bundler/utils.d.cts +2 -2
- package/dist/bundler/utils.d.ts +2 -2
- package/dist/bundler/utils.js +2 -2
- package/dist/{client-C3jHSAqV.cjs → client-CuivP4z0.cjs} +3 -3
- package/dist/client-CuivP4z0.cjs.map +1 -0
- package/dist/{client-DUlrjus0.js → client-DzeqTq6Y.js} +3 -3
- package/dist/client-DzeqTq6Y.js.map +1 -0
- package/dist/commander-kit/index.cjs +5 -5
- package/dist/commander-kit/index.cjs.map +1 -1
- package/dist/commander-kit/index.d.cts +3 -3
- package/dist/commander-kit/index.d.ts +3 -3
- package/dist/commander-kit/index.js +5 -5
- package/dist/commander-kit/index.js.map +1 -1
- package/dist/{extra-CsRmdXC4.d.cts → extra-BleSbKJp.d.ts} +2 -2
- package/dist/{extra-DxvrBev9.d.ts → extra-C8r3KWjP.d.cts} +2 -2
- package/dist/{fast-globe-options-PH-bHWVK.d.cts → fast-globe-options-D7S2fQZZ.d.cts} +3 -3
- package/dist/{fast-globe-options-Cz8KJqKc.d.ts → fast-globe-options-DnV58KJc.d.ts} +3 -3
- package/dist/{helper-D11A-ZKL.js → helper-C0AShk-j.js} +2 -2
- package/dist/{helper-D11A-ZKL.js.map → helper-C0AShk-j.js.map} +1 -1
- package/dist/{helper-DpeqwciR.cjs → helper-DNj9Sj4w.cjs} +2 -2
- package/dist/{helper-DpeqwciR.cjs.map → helper-DNj9Sj4w.cjs.map} +1 -1
- package/dist/{identity-C5MeSAA7.js → identity-CcYkvy9q.js} +6 -6
- package/dist/{identity-C5MeSAA7.js.map → identity-CcYkvy9q.js.map} +1 -1
- package/dist/{identity-ByjqnR8L.cjs → identity-Crq3bzhv.cjs} +6 -6
- package/dist/{identity-ByjqnR8L.cjs.map → identity-Crq3bzhv.cjs.map} +1 -1
- package/dist/{index-xAz8brx-.d.cts → index-BdtMQyzF.d.cts} +2 -2
- package/dist/{index-Dvmmz0f_.d.ts → index-CwHGSras.d.ts} +2 -2
- package/dist/{index-TgjbNRWB.d.cts → index-DlH2PDPD.d.cts} +2 -2
- package/dist/{index-B1t7Xs3T.d.ts → index-NLQcJJFO.d.ts} +2 -2
- package/dist/index.cjs +176 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -48
- package/dist/index.d.ts +81 -48
- package/dist/index.js +176 -104
- package/dist/index.js.map +1 -1
- package/dist/{package-banner-ByfR7yCv.cjs → package-banner-BoS7Lbi9.cjs} +5 -5
- package/dist/{package-banner-ByfR7yCv.cjs.map → package-banner-BoS7Lbi9.cjs.map} +1 -1
- package/dist/{package-banner-vwqcAX8E.js → package-banner-DkNDAjMK.js} +5 -5
- package/dist/{package-banner-vwqcAX8E.js.map → package-banner-DkNDAjMK.js.map} +1 -1
- package/dist/{server-BK6eykjo.cjs → server-CvLC0e2m.cjs} +3 -3
- package/dist/{server-BK6eykjo.cjs.map → server-CvLC0e2m.cjs.map} +1 -1
- package/dist/{server-1H2HFAbi.js → server-Dc93jndm.js} +3 -3
- package/dist/{server-1H2HFAbi.js.map → server-Dc93jndm.js.map} +1 -1
- package/dist/utils/client.cjs +2 -2
- package/dist/utils/client.d.cts +25 -7
- package/dist/utils/client.d.ts +25 -7
- package/dist/utils/client.js +2 -2
- package/dist/utils/server.cjs +2 -2
- package/dist/utils/server.d.cts +2 -2
- package/dist/utils/server.d.ts +2 -2
- package/dist/utils/server.js +2 -2
- package/package.json +4 -2
- package/dist/client-C3jHSAqV.cjs.map +0 -1
- package/dist/client-DUlrjus0.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.11`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { S as toStringSet, _ as isUndefined, a as isError, d as isNumber, g as isString, h as isSet, i as isBoolean, l as isNonEmptyString, m as isRegExp, n as flattenStrings, p as isPlainObject, r as isArray, v as normalizeSpaces, x as toObjectSet, y as safeStableStringify } from "./helper-
|
|
12
|
-
import { a as resolvePatternOptions, i as defaultPatternOptions, n as fsExtra, o as sourceOfPatternOptions, r as ICONS, t as fastGlob } from "./server-
|
|
13
|
-
import { t as CommandIdentity } from "./identity-
|
|
14
|
-
import { a as joinInline, i as formatOptionValue, l as picocolors, n as EOL, o as joinLines, s as joinLinesLoose, u as plural } from "./client-
|
|
15
|
-
import { n as getPackageJson, t as generatePackageBanner } from "./package-banner-
|
|
11
|
+
import { S as toStringSet, _ as isUndefined, a as isError, d as isNumber, g as isString, h as isSet, i as isBoolean, l as isNonEmptyString, m as isRegExp, n as flattenStrings, p as isPlainObject, r as isArray, v as normalizeSpaces, x as toObjectSet, y as safeStableStringify } from "./helper-C0AShk-j.js";
|
|
12
|
+
import { a as resolvePatternOptions, i as defaultPatternOptions, n as fsExtra, o as sourceOfPatternOptions, r as ICONS, t as fastGlob } from "./server-Dc93jndm.js";
|
|
13
|
+
import { t as CommandIdentity } from "./identity-CcYkvy9q.js";
|
|
14
|
+
import { a as joinInline, i as formatOptionValue, l as picocolors, n as EOL, o as joinLines, s as joinLinesLoose, u as plural } from "./client-DzeqTq6Y.js";
|
|
15
|
+
import { n as getPackageJson, t as generatePackageBanner } from "./package-banner-DkNDAjMK.js";
|
|
16
16
|
import "@rzl-zone/node-only";
|
|
17
17
|
import * as t from "@babel/types";
|
|
18
18
|
import { parse } from "@babel/parser";
|
|
19
19
|
import traverseImport from "@babel/traverse";
|
|
20
20
|
import path from "node:path";
|
|
21
|
+
import { parse as parse$2 } from "shell-quote";
|
|
21
22
|
import { ChildProcess, spawn } from "node:child_process";
|
|
22
23
|
import * as acorn from "acorn";
|
|
23
24
|
function isLogLevel(value) {
|
|
@@ -1155,31 +1156,44 @@ const normalizeJsBuildNewlines = async (pattern, options = {}) => {
|
|
|
1155
1156
|
}
|
|
1156
1157
|
};
|
|
1157
1158
|
function runCommand(command, argsOrOptions = [], maybeOptions = {}) {
|
|
1158
|
-
assertValidCommand(command);
|
|
1159
|
-
let args;
|
|
1160
|
-
let options;
|
|
1161
|
-
if (Array.isArray(argsOrOptions)) {
|
|
1162
|
-
args = argsOrOptions;
|
|
1163
|
-
options = maybeOptions;
|
|
1164
|
-
} else {
|
|
1165
|
-
args = [];
|
|
1166
|
-
options = argsOrOptions;
|
|
1167
|
-
}
|
|
1168
1159
|
return new Promise((resolve, reject) => {
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1160
|
+
try {
|
|
1161
|
+
let args;
|
|
1162
|
+
let options;
|
|
1163
|
+
const isArgsArray = isArray(argsOrOptions);
|
|
1164
|
+
if (isArgsArray) {
|
|
1165
|
+
args = argsOrOptions;
|
|
1166
|
+
options = maybeOptions;
|
|
1167
|
+
} else {
|
|
1168
|
+
args = [];
|
|
1169
|
+
options = argsOrOptions;
|
|
1170
|
+
}
|
|
1171
|
+
assertValidCommand(command, {
|
|
1172
|
+
apiType: "runCommand",
|
|
1173
|
+
useColors: options.useColors,
|
|
1174
|
+
allowInline: !isArgsArray
|
|
1175
|
+
});
|
|
1176
|
+
const { shell = true, stdio = "inherit", argv0: _argv0, useColors = true, ...restOption } = options;
|
|
1177
|
+
const { child, setupLifecycle, cmdStringPlain } = spawnWithLifecycle(command, args, {
|
|
1178
|
+
...restOption,
|
|
1179
|
+
stdio,
|
|
1180
|
+
useColors,
|
|
1181
|
+
shell
|
|
1182
|
+
}, { rejectOnNonZero: true });
|
|
1183
|
+
setupLifecycle({
|
|
1184
|
+
onSuccess: (code) => {
|
|
1185
|
+
if (code === 0) resolve(child);
|
|
1186
|
+
else reject(/* @__PURE__ */ new Error(`${cmdStringPlain} exited with code ${code}`));
|
|
1187
|
+
},
|
|
1188
|
+
onError: reject
|
|
1189
|
+
});
|
|
1190
|
+
} catch (err) {
|
|
1191
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
1192
|
+
const cleanedBase = stripInternalStack(((/* @__PURE__ */ new Error()).stack?.split(EOL).slice(1) ?? []).filter((line) => !line.includes("runCommand")));
|
|
1193
|
+
e.stack = [e.message, ...cleanedBase].join(EOL);
|
|
1194
|
+
reject(e);
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1183
1197
|
});
|
|
1184
1198
|
}
|
|
1185
1199
|
function normalizeChunk(chunk) {
|
|
@@ -1188,74 +1202,89 @@ function normalizeChunk(chunk) {
|
|
|
1188
1202
|
return String(chunk);
|
|
1189
1203
|
}
|
|
1190
1204
|
function runCommandCapture(command, argsOrOptions = [], maybeOptions = {}) {
|
|
1191
|
-
assertValidCommand(command);
|
|
1192
|
-
let args;
|
|
1193
|
-
let options;
|
|
1194
|
-
if (Array.isArray(argsOrOptions)) {
|
|
1195
|
-
args = argsOrOptions;
|
|
1196
|
-
options = maybeOptions;
|
|
1197
|
-
} else {
|
|
1198
|
-
args = [];
|
|
1199
|
-
options = argsOrOptions;
|
|
1200
|
-
}
|
|
1201
|
-
const { shell = true, signal, timeout, forceKill, useColors = true, argv0: _argv0, ...restOption } = options;
|
|
1202
1205
|
return new Promise((resolve, reject) => {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
},
|
|
1229
|
-
|
|
1230
|
-
|
|
1206
|
+
try {
|
|
1207
|
+
let args;
|
|
1208
|
+
let options;
|
|
1209
|
+
const isArgsArray = isArray(argsOrOptions);
|
|
1210
|
+
if (isArgsArray) {
|
|
1211
|
+
args = argsOrOptions;
|
|
1212
|
+
options = maybeOptions;
|
|
1213
|
+
} else {
|
|
1214
|
+
args = [];
|
|
1215
|
+
options = argsOrOptions;
|
|
1216
|
+
}
|
|
1217
|
+
assertValidCommand(command, {
|
|
1218
|
+
apiType: "runCommandCapture",
|
|
1219
|
+
useColors: options.useColors,
|
|
1220
|
+
allowInline: !isArgsArray
|
|
1221
|
+
});
|
|
1222
|
+
const { shell = true, signal, timeout, forceKill, useColors = true, argv0: _argv0, ...restOption } = options;
|
|
1223
|
+
const { child, setupLifecycle } = spawnWithLifecycle(command, args, {
|
|
1224
|
+
...restOption,
|
|
1225
|
+
stdio: "pipe",
|
|
1226
|
+
shell,
|
|
1227
|
+
signal,
|
|
1228
|
+
timeout,
|
|
1229
|
+
forceKill,
|
|
1230
|
+
useColors
|
|
1231
|
+
}, { rejectOnNonZero: false });
|
|
1232
|
+
let stdout = "";
|
|
1233
|
+
let stderr = "";
|
|
1234
|
+
child.stdout?.on("data", (chunk) => {
|
|
1235
|
+
stdout += normalizeChunk(chunk);
|
|
1236
|
+
});
|
|
1237
|
+
child.stderr?.on("data", (chunk) => {
|
|
1238
|
+
stderr += normalizeChunk(chunk);
|
|
1239
|
+
});
|
|
1240
|
+
setupLifecycle({
|
|
1241
|
+
onSuccess: (code) => {
|
|
1242
|
+
resolve({
|
|
1243
|
+
stdout: stdout.trimEnd(),
|
|
1244
|
+
stderr: formatMessageColor(stderr.trimEnd(), useColors),
|
|
1245
|
+
exitCode: code,
|
|
1246
|
+
ok: code === 0
|
|
1247
|
+
});
|
|
1248
|
+
},
|
|
1249
|
+
onError: reject
|
|
1250
|
+
});
|
|
1251
|
+
} catch (err) {
|
|
1252
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
1253
|
+
const cleanedBase = stripInternalStack(((/* @__PURE__ */ new Error()).stack?.split(EOL).slice(1) ?? []).filter((line) => !line.includes("runCommandCapture")));
|
|
1254
|
+
e.stack = [e.message, ...cleanedBase].join(EOL);
|
|
1255
|
+
reject(e);
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1231
1258
|
});
|
|
1232
1259
|
}
|
|
1260
|
+
const formatMessageColor = (message, useColors = true) => {
|
|
1261
|
+
return useColors ? picocolors.redBright(message) : message;
|
|
1262
|
+
};
|
|
1233
1263
|
function formatCommand(command, args, { useColors = true } = {}) {
|
|
1234
1264
|
const hasArgs = args.length > 0;
|
|
1235
1265
|
const argsString = hasArgs ? args.map((a) => safeStableStringify(a)).join(" ") : "";
|
|
1236
|
-
if (useColors)
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
}
|
|
1240
|
-
return hasArgs ? `${command} ${argsString}` : command;
|
|
1266
|
+
if (!hasArgs) return formatMessageColor(command, useColors);
|
|
1267
|
+
if (useColors) return `${picocolors.cyanBright(command)} ${picocolors.gray(argsString)}`;
|
|
1268
|
+
return `${command} ${argsString}`;
|
|
1241
1269
|
}
|
|
1242
|
-
function assertValidCommand(command,
|
|
1243
|
-
|
|
1270
|
+
function assertValidCommand(command, options) {
|
|
1271
|
+
const { useColors = true, allowInline = false, apiType } = options || {};
|
|
1272
|
+
if (!isString(command)) {
|
|
1244
1273
|
const errorMsg = `Invalid command: expected a string, received ${safeStableStringify(command)}`;
|
|
1245
|
-
throw new TypeError(
|
|
1274
|
+
throw new TypeError(formatMessageColor(errorMsg, useColors));
|
|
1246
1275
|
}
|
|
1247
1276
|
const trimmed = command.trim();
|
|
1248
|
-
if (trimmed.length === 0)
|
|
1249
|
-
|
|
1250
|
-
|
|
1277
|
+
if (trimmed.length === 0) throw new Error(formatMessageColor("Invalid command: command cannot be empty", useColors));
|
|
1278
|
+
const hasSpace = /\s/.test(trimmed);
|
|
1279
|
+
if (hasShellSyntax(trimmed)) {
|
|
1280
|
+
const errorMsg = joinLinesLoose(`Invalid command: "${trimmed}"`, "Shell operators are not supported in this context (e.g. &&, ||, |, >).", "This utility only supports a single command with arguments.");
|
|
1281
|
+
throw new Error(formatMessageColor(errorMsg, useColors));
|
|
1251
1282
|
}
|
|
1252
|
-
|
|
1253
|
-
const hasQuotes = /['"`]/.test(trimmed);
|
|
1254
|
-
const hasShellOps = /[|&;<>(){}$]/.test(trimmed);
|
|
1255
|
-
if (hasSpace || hasQuotes || hasShellOps) {
|
|
1283
|
+
if (!allowInline && hasSpace) {
|
|
1256
1284
|
const [cmd, ...rest] = trimmed.split(/\s+/);
|
|
1257
|
-
|
|
1258
|
-
|
|
1285
|
+
if (!cmd) throw new Error("Invalid command: unable to resolve executable.");
|
|
1286
|
+
const errorMsg = joinLinesLoose(`Invalid command: "${trimmed}"`, "Do not include arguments in the command when passing them separately.", `Use: ${apiType}("${cmd}", ${safeStableStringify(rest)})`);
|
|
1287
|
+
throw new Error(formatMessageColor(errorMsg, useColors));
|
|
1259
1288
|
}
|
|
1260
1289
|
}
|
|
1261
1290
|
function stripInternalStack(lines) {
|
|
@@ -1267,8 +1296,10 @@ function stripInternalStack(lines) {
|
|
|
1267
1296
|
"createProcessError",
|
|
1268
1297
|
"formatError",
|
|
1269
1298
|
"spawnWithLifecycle",
|
|
1299
|
+
"assertValidCommand",
|
|
1270
1300
|
"setupLifecycle",
|
|
1271
|
-
"node:internal"
|
|
1301
|
+
"node:internal",
|
|
1302
|
+
"node:internal/process/promises"
|
|
1272
1303
|
];
|
|
1273
1304
|
return lines.filter((line) => {
|
|
1274
1305
|
if (blacklist.some((key) => line.includes(key))) return false;
|
|
@@ -1335,29 +1366,70 @@ var CommandProcessError = class extends Error {
|
|
|
1335
1366
|
function isCommandProcessError(err) {
|
|
1336
1367
|
return err instanceof CommandProcessError;
|
|
1337
1368
|
}
|
|
1369
|
+
function hasShellSyntax(str) {
|
|
1370
|
+
return /(\|\||&&|[|&;<>\n])/.test(str);
|
|
1371
|
+
}
|
|
1372
|
+
function resolveCommand(input, useColors = true) {
|
|
1373
|
+
const tokens = parse$2(input);
|
|
1374
|
+
const normalized = [];
|
|
1375
|
+
for (const t of tokens) {
|
|
1376
|
+
if (typeof t === "string") {
|
|
1377
|
+
normalized.push(t);
|
|
1378
|
+
continue;
|
|
1379
|
+
}
|
|
1380
|
+
if ("comment" in t) continue;
|
|
1381
|
+
if ("pattern" in t) {
|
|
1382
|
+
normalized.push(t.pattern);
|
|
1383
|
+
continue;
|
|
1384
|
+
}
|
|
1385
|
+
if ("op" in t) throw new Error(formatMessageColor("Unsupported shell operator detected.", useColors));
|
|
1386
|
+
throw new Error(formatMessageColor("Unknown token in command.", useColors));
|
|
1387
|
+
}
|
|
1388
|
+
if (normalized.length === 0) throw new Error(formatMessageColor("Invalid command: empty after parsing.", useColors));
|
|
1389
|
+
const [cmd, ...args] = normalized;
|
|
1390
|
+
if (!cmd) throw new Error(formatMessageColor("Invalid command: empty after parsing.", useColors));
|
|
1391
|
+
return {
|
|
1392
|
+
command: cmd,
|
|
1393
|
+
args
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1338
1396
|
function spawnWithLifecycle(command, args, options, config) {
|
|
1339
|
-
const { useColors = true, timeout, forceKill, signal: abortSignal, ...restOption } = options;
|
|
1397
|
+
const { useColors = true, timeout, forceKill, signal: abortSignal, shell = false, ...restOption } = options;
|
|
1398
|
+
let cmd = command;
|
|
1399
|
+
let finalArgs = [...args];
|
|
1400
|
+
const isInline = finalArgs.length === 0 && /\s/.test(cmd);
|
|
1340
1401
|
const baseStack = (/* @__PURE__ */ new Error()).stack;
|
|
1341
|
-
const cmdString = formatCommand(command, args, { useColors });
|
|
1342
|
-
const cmdStringPlain = formatCommand(command, args, { useColors: false });
|
|
1343
1402
|
const formatError = config?.formatError ?? ((msg, meta) => {
|
|
1344
1403
|
const metaCommand = meta.command.trim();
|
|
1345
|
-
const
|
|
1404
|
+
const hasArgs = meta.args.length > 0;
|
|
1405
|
+
const argsString = hasArgs ? meta.args.map((a) => safeStableStringify(a).trim()).join(" ") : "";
|
|
1406
|
+
const commandString = hasArgs ? `${metaCommand} ${argsString}` : metaCommand;
|
|
1346
1407
|
if (meta.useColors) {
|
|
1347
1408
|
const cmd = picocolors.magentaBright(metaCommand);
|
|
1348
|
-
const args =
|
|
1409
|
+
const args = hasArgs ? picocolors.yellowBright(argsString) : "";
|
|
1349
1410
|
return createProcessError(`${cmd}${args ? " " + args : ""} ${picocolors.redBright(msg)}`, {
|
|
1350
1411
|
...meta,
|
|
1351
|
-
command:
|
|
1412
|
+
command: commandString
|
|
1352
1413
|
}, baseStack);
|
|
1353
1414
|
}
|
|
1354
|
-
return createProcessError(`${
|
|
1415
|
+
return createProcessError(`${commandString} ${msg}`, {
|
|
1355
1416
|
...meta,
|
|
1356
|
-
command:
|
|
1417
|
+
command: commandString
|
|
1357
1418
|
}, baseStack);
|
|
1358
1419
|
});
|
|
1359
1420
|
const rejectOnNonZero = config?.rejectOnNonZero ?? false;
|
|
1360
|
-
|
|
1421
|
+
if (isInline) {
|
|
1422
|
+
const resolved = resolveCommand(cmd, useColors);
|
|
1423
|
+
cmd = resolved.command;
|
|
1424
|
+
finalArgs = resolved.args;
|
|
1425
|
+
}
|
|
1426
|
+
for (const arg of finalArgs) if (hasShellSyntax(arg)) throw new Error(formatMessageColor(`Invalid argument: "${arg}" contains unsupported shell syntax`, useColors));
|
|
1427
|
+
const cmdString = formatCommand(cmd, finalArgs, { useColors });
|
|
1428
|
+
const cmdStringPlain = formatCommand(cmd, finalArgs, { useColors: false });
|
|
1429
|
+
const child = spawn(cmd, finalArgs, {
|
|
1430
|
+
shell,
|
|
1431
|
+
...restOption
|
|
1432
|
+
});
|
|
1361
1433
|
let finished = false;
|
|
1362
1434
|
const kill = () => {
|
|
1363
1435
|
try {
|
|
@@ -1382,8 +1454,8 @@ function spawnWithLifecycle(command, args, options, config) {
|
|
|
1382
1454
|
kill();
|
|
1383
1455
|
fail(formatError(`timed out after ${timeout}ms`, {
|
|
1384
1456
|
reason: "timeout",
|
|
1385
|
-
command,
|
|
1386
|
-
args,
|
|
1457
|
+
command: cmd,
|
|
1458
|
+
args: finalArgs,
|
|
1387
1459
|
useColors
|
|
1388
1460
|
}));
|
|
1389
1461
|
}, timeout) : null;
|
|
@@ -1407,8 +1479,8 @@ function spawnWithLifecycle(command, args, options, config) {
|
|
|
1407
1479
|
kill();
|
|
1408
1480
|
fail(formatError("aborted by signal", {
|
|
1409
1481
|
reason: "abort",
|
|
1410
|
-
command,
|
|
1411
|
-
args,
|
|
1482
|
+
command: cmd,
|
|
1483
|
+
args: finalArgs,
|
|
1412
1484
|
useColors
|
|
1413
1485
|
}));
|
|
1414
1486
|
};
|
|
@@ -1426,8 +1498,8 @@ function spawnWithLifecycle(command, args, options, config) {
|
|
|
1426
1498
|
reason: "signal",
|
|
1427
1499
|
signal,
|
|
1428
1500
|
exitCode: code ?? void 0,
|
|
1429
|
-
command,
|
|
1430
|
-
args,
|
|
1501
|
+
command: cmd,
|
|
1502
|
+
args: finalArgs,
|
|
1431
1503
|
useColors
|
|
1432
1504
|
}));
|
|
1433
1505
|
return;
|
|
@@ -1437,8 +1509,8 @@ function spawnWithLifecycle(command, args, options, config) {
|
|
|
1437
1509
|
fail(formatError(`exited with code ${exitCode}`, {
|
|
1438
1510
|
reason: "non-zero exit code",
|
|
1439
1511
|
exitCode,
|
|
1440
|
-
command,
|
|
1441
|
-
args,
|
|
1512
|
+
command: cmd,
|
|
1513
|
+
args: finalArgs,
|
|
1442
1514
|
useColors
|
|
1443
1515
|
}));
|
|
1444
1516
|
return;
|