npm-pkg-lint 5.4.2 → 5.5.0
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/index.js +202 -99
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8153,116 +8153,167 @@ import process3 from "node:process";
|
|
|
8153
8153
|
import { stripVTControlCharacters } from "node:util";
|
|
8154
8154
|
var getContext = (raw) => ({
|
|
8155
8155
|
start: process3.hrtime.bigint(),
|
|
8156
|
-
command: raw.map((part) => getCommandPart(
|
|
8156
|
+
command: raw.map((part) => getCommandPart(part)).join(" "),
|
|
8157
8157
|
state: {
|
|
8158
8158
|
stdout: "",
|
|
8159
8159
|
stderr: "",
|
|
8160
8160
|
output: "",
|
|
8161
|
-
isIterating: {}
|
|
8162
|
-
nonIterable: [false, false]
|
|
8161
|
+
isIterating: { __proto__: null }
|
|
8163
8162
|
}
|
|
8164
8163
|
});
|
|
8165
|
-
var
|
|
8164
|
+
var namedControlCharacters = /* @__PURE__ */ new Map([[9, "t"], [10, "n"], [13, "r"]]);
|
|
8165
|
+
var isControlCharacter = (codePoint) => codePoint < 32 || codePoint >= 127 && codePoint <= 159;
|
|
8166
|
+
var escapeControlCharacter = (codePoint) => "\\" + (namedControlCharacters.get(codePoint) ?? `x${codePoint.toString(16).padStart(2, "0")}`);
|
|
8167
|
+
var getCommandPart = (part) => {
|
|
8168
|
+
let escaped = "";
|
|
8169
|
+
for (const character of stripVTControlCharacters(part)) {
|
|
8170
|
+
const codePoint = character.codePointAt(0);
|
|
8171
|
+
escaped += isControlCharacter(codePoint) ? escapeControlCharacter(codePoint) : character;
|
|
8172
|
+
}
|
|
8173
|
+
return new RegExp("[^\\w\\-.\\/]", "v").test(escaped) ? `'${escaped.replaceAll("'", "'\\''")}'` : escaped;
|
|
8174
|
+
};
|
|
8166
8175
|
|
|
8167
8176
|
// node_modules/nano-spawn/source/options.js
|
|
8168
8177
|
import path7 from "node:path";
|
|
8169
8178
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
8170
8179
|
import process4 from "node:process";
|
|
8171
8180
|
var getOptions = ({
|
|
8181
|
+
input,
|
|
8172
8182
|
stdin,
|
|
8173
8183
|
stdout,
|
|
8174
8184
|
stderr,
|
|
8175
|
-
stdio
|
|
8185
|
+
stdio,
|
|
8176
8186
|
env: envOption,
|
|
8177
8187
|
preferLocal,
|
|
8178
8188
|
cwd: cwdOption = ".",
|
|
8179
8189
|
...options
|
|
8180
8190
|
}) => {
|
|
8191
|
+
for (const [optionName, value] of [["cwd", cwdOption], ["stdio", stdio]]) {
|
|
8192
|
+
if (value === null) {
|
|
8193
|
+
throw new TypeError(`The \`${optionName}\` option must not be \`null\`. Use \`undefined\` instead.`);
|
|
8194
|
+
}
|
|
8195
|
+
}
|
|
8196
|
+
validateStdin("stdin", stdin);
|
|
8197
|
+
if (input !== void 0 && (stdin !== void 0 || stdio !== void 0)) {
|
|
8198
|
+
throw new TypeError("The `input` option cannot be used with the `stdin` or `stdio` options.");
|
|
8199
|
+
}
|
|
8181
8200
|
const cwd = cwdOption instanceof URL ? fileURLToPath3(cwdOption) : path7.resolve(cwdOption);
|
|
8182
|
-
const env =
|
|
8183
|
-
const
|
|
8201
|
+
const env = { __proto__: null, ...process4.env, ...envOption };
|
|
8202
|
+
const stdioOption = Array.isArray(stdio) ? [...stdio] : stdio ?? [stdin, stdout, stderr];
|
|
8203
|
+
if (Array.isArray(stdio)) {
|
|
8204
|
+
validateStdin("stdio", stdioOption[0]);
|
|
8205
|
+
}
|
|
8184
8206
|
return {
|
|
8207
|
+
__proto__: null,
|
|
8185
8208
|
...options,
|
|
8186
8209
|
input,
|
|
8187
|
-
stdio:
|
|
8188
|
-
env: preferLocal ? addLocalPath(env
|
|
8210
|
+
stdio: stdioOption,
|
|
8211
|
+
env: preferLocal ? addLocalPath(env, cwd) : env,
|
|
8189
8212
|
cwd
|
|
8190
8213
|
};
|
|
8191
8214
|
};
|
|
8215
|
+
var stdioDirectives = /* @__PURE__ */ new Set(["pipe", "inherit", "ignore", "ipc", "overlapped"]);
|
|
8216
|
+
var validateStdin = (optionName, value) => {
|
|
8217
|
+
if (typeof value === "string" && !stdioDirectives.has(value)) {
|
|
8218
|
+
throw new TypeError(`The \`${optionName}\` option must be "pipe", "inherit", "ignore", "ipc" or "overlapped", a \`Stream\`, or a file descriptor. To pass input as a string, use the \`input\` option instead.`);
|
|
8219
|
+
}
|
|
8220
|
+
if (typeof value === "object" && value !== null && "string" in value) {
|
|
8221
|
+
throw new TypeError(`The \`${optionName}\` option does not accept \`{string: ...}\` anymore. Use the \`input\` option instead.`);
|
|
8222
|
+
}
|
|
8223
|
+
};
|
|
8192
8224
|
var addLocalPath = ({ Path = "", PATH = Path, ...env }, cwd) => {
|
|
8193
|
-
const pathParts = PATH.split(path7.delimiter);
|
|
8194
|
-
const localPaths = getLocalPaths([], path7.resolve(cwd)).map((localPath) => path7.join(localPath, "node_modules/.bin")).filter((localPath) => !pathParts.
|
|
8195
|
-
return { ...env, PATH: [...localPaths, PATH].filter(Boolean).join(path7.delimiter) };
|
|
8225
|
+
const pathParts = new Set(PATH.split(path7.delimiter));
|
|
8226
|
+
const localPaths = getLocalPaths([], path7.resolve(cwd)).map((localPath) => path7.join(localPath, "node_modules/.bin")).filter((localPath) => !pathParts.has(localPath));
|
|
8227
|
+
return { __proto__: null, ...env, PATH: [...localPaths, PATH].filter(Boolean).join(path7.delimiter) };
|
|
8196
8228
|
};
|
|
8197
8229
|
var getLocalPaths = (localPaths, localPath) => localPaths.at(-1) === localPath ? localPaths : getLocalPaths([...localPaths, localPath], path7.resolve(localPath, ".."));
|
|
8198
8230
|
|
|
8199
8231
|
// node_modules/nano-spawn/source/spawn.js
|
|
8200
8232
|
import { spawn } from "node:child_process";
|
|
8201
|
-
import { once
|
|
8233
|
+
import { once } from "node:events";
|
|
8202
8234
|
import process7 from "node:process";
|
|
8203
8235
|
|
|
8204
8236
|
// node_modules/nano-spawn/source/windows.js
|
|
8205
8237
|
import fs5 from "node:fs/promises";
|
|
8206
8238
|
import path8 from "node:path";
|
|
8207
8239
|
import process5 from "node:process";
|
|
8208
|
-
var applyForceShell = async (file, commandArguments, options) => await shouldForceShell(file, options) ? [escapeFile(file), commandArguments.map((argument) => escapeArgument(argument)), { ...options, shell: true }] : [file, commandArguments, options];
|
|
8209
|
-
var shouldForceShell = async (file, { shell, cwd, env
|
|
8240
|
+
var applyForceShell = async (file, commandArguments, options) => await shouldForceShell(file, options) ? [escapeFile(file), commandArguments.map((argument) => escapeArgument(argument)), { __proto__: null, ...options, shell: true }] : [file, commandArguments, options];
|
|
8241
|
+
var shouldForceShell = async (file, { shell, cwd, env }) => process5.platform === "win32" && !shell && !await isExe(file, cwd, env);
|
|
8210
8242
|
var isExe = (file, cwd, { Path = "", PATH = Path }) => (
|
|
8211
8243
|
// If the *.exe or *.com file extension was not omitted.
|
|
8212
8244
|
// Windows common file systems are case-insensitive.
|
|
8213
|
-
exeExtensions.some((extension2) => file.toLowerCase().endsWith(extension2)) ||
|
|
8214
|
-
);
|
|
8215
|
-
var EXE_MEMO = {};
|
|
8216
|
-
var memoize = (function_) => (...arguments_) => (
|
|
8217
|
-
// Use returned assignment to keep code small
|
|
8218
|
-
EXE_MEMO[arguments_.join("\0")] ??= function_(...arguments_)
|
|
8245
|
+
exeExtensions.some((extension2) => file.toLowerCase().endsWith(extension2)) || hasNativeExecutable(file, cwd, PATH)
|
|
8219
8246
|
);
|
|
8220
|
-
var
|
|
8221
|
-
|
|
8222
|
-
const parts = PATH.split(path8.delimiter).filter(Boolean).map((part) => part.replace(/^"(.*)"$/, "$1"));
|
|
8247
|
+
var hasNativeExecutable = async (file, cwd, PATH) => {
|
|
8248
|
+
const parts = PATH.split(path8.delimiter).filter(Boolean).map((part) => part.replace(new RegExp('^"(?<quoted>.*)"$', "v"), "$<quoted>"));
|
|
8223
8249
|
try {
|
|
8224
8250
|
await Promise.any(
|
|
8225
8251
|
[cwd, ...parts].flatMap(
|
|
8226
|
-
(part) => exeExtensions.map((extension2) => access(`${path8.resolve(part, file)}${extension2}`))
|
|
8252
|
+
(part) => exeExtensions.map((extension2) => fs5.access(`${path8.resolve(cwd, part, file)}${extension2}`))
|
|
8227
8253
|
)
|
|
8228
8254
|
);
|
|
8229
8255
|
} catch {
|
|
8230
8256
|
return false;
|
|
8231
8257
|
}
|
|
8232
8258
|
return true;
|
|
8233
|
-
}
|
|
8259
|
+
};
|
|
8234
8260
|
var exeExtensions = [".exe", ".com"];
|
|
8235
|
-
var escapeArgument = (argument) =>
|
|
8236
|
-
|
|
8261
|
+
var escapeArgument = (argument) => {
|
|
8262
|
+
if (!shouldQuoteArgument(argument)) {
|
|
8263
|
+
return argument;
|
|
8264
|
+
}
|
|
8265
|
+
const escapedArgument = argument.replaceAll(new RegExp("\\\\+", "gv"), (backslashes, offset) => ['"', void 0].includes(argument[offset + backslashes.length]) ? backslashes.repeat(2) : backslashes).replaceAll('"', '""').replaceAll("%", "%%cd:~,%");
|
|
8266
|
+
return `"${escapedArgument}"`;
|
|
8267
|
+
};
|
|
8268
|
+
var shouldQuoteArgument = (argument) => argument === "" || argument.endsWith("\\") || new RegExp("[\\p{Control}[^\\w#$*+\\-.\\/:?@\\\\\\u{80}-\\u{10FFFF}]]", "v").test(argument);
|
|
8269
|
+
var escapeFile = (file) => file.replaceAll(new RegExp('(?<special>[ !"%&\\(\\)*,;<>?\\[\\]^`\\|])', "gv"), "^$<special>");
|
|
8237
8270
|
|
|
8238
8271
|
// node_modules/nano-spawn/source/result.js
|
|
8239
|
-
import { once, on } from "node:events";
|
|
8240
8272
|
import process6 from "node:process";
|
|
8241
8273
|
var getResult = async (nodeChildProcess, options, context) => {
|
|
8242
8274
|
const instance = await nodeChildProcess;
|
|
8243
8275
|
if (options.input !== void 0) {
|
|
8244
8276
|
instance.stdin.end(options.input);
|
|
8245
8277
|
}
|
|
8246
|
-
const onClose = once(instance, "close");
|
|
8247
8278
|
try {
|
|
8248
|
-
await
|
|
8249
|
-
onClose,
|
|
8250
|
-
...instance.stdio.filter(Boolean).map((stream) => onStreamError(stream))
|
|
8251
|
-
]);
|
|
8279
|
+
await waitForCompletion(instance);
|
|
8252
8280
|
checkFailure(context, getErrorOutput(instance));
|
|
8253
8281
|
return getOutputs(context);
|
|
8254
8282
|
} catch (error) {
|
|
8255
|
-
await Promise.allSettled([onClose]);
|
|
8256
8283
|
throw getResultError(error, instance, context, options);
|
|
8257
8284
|
}
|
|
8258
8285
|
};
|
|
8259
|
-
var
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8286
|
+
var waitForCompletion = (instance) => new Promise((resolve, reject) => {
|
|
8287
|
+
let cancellationError;
|
|
8288
|
+
const onInstanceError = (error) => {
|
|
8289
|
+
if (error.code === "ABORT_ERR") {
|
|
8290
|
+
cancellationError = error;
|
|
8291
|
+
} else {
|
|
8292
|
+
reject(error);
|
|
8293
|
+
}
|
|
8294
|
+
};
|
|
8295
|
+
const streams = instance.stdio.filter(Boolean);
|
|
8296
|
+
const onStreamError = (error) => {
|
|
8297
|
+
if (!["ERR_STREAM_PREMATURE_CLOSE", "EPIPE", "EOF"].includes(error?.code)) {
|
|
8298
|
+
reject(error);
|
|
8263
8299
|
}
|
|
8300
|
+
};
|
|
8301
|
+
for (const stream of streams) {
|
|
8302
|
+
stream.on("error", onStreamError);
|
|
8264
8303
|
}
|
|
8265
|
-
|
|
8304
|
+
instance.on("error", onInstanceError);
|
|
8305
|
+
instance.once("close", () => {
|
|
8306
|
+
instance.off("error", onInstanceError);
|
|
8307
|
+
for (const stream of streams) {
|
|
8308
|
+
stream.off("error", onStreamError);
|
|
8309
|
+
}
|
|
8310
|
+
if (cancellationError === void 0) {
|
|
8311
|
+
resolve();
|
|
8312
|
+
} else {
|
|
8313
|
+
reject(cancellationError);
|
|
8314
|
+
}
|
|
8315
|
+
});
|
|
8316
|
+
});
|
|
8266
8317
|
var checkFailure = ({ command }, { exitCode, signalName }) => {
|
|
8267
8318
|
if (signalName !== void 0) {
|
|
8268
8319
|
throw new SubprocessError(`Command was terminated with ${signalName}: ${command}`);
|
|
@@ -8283,8 +8334,8 @@ var SubprocessError = class extends Error {
|
|
|
8283
8334
|
};
|
|
8284
8335
|
var getErrorOutput = ({ exitCode, signalCode }) => ({
|
|
8285
8336
|
// `exitCode` can be a negative number (`errno`) when the `error` event is emitted on the `instance`
|
|
8286
|
-
|
|
8287
|
-
...signalCode
|
|
8337
|
+
...!(exitCode < 1) && { exitCode },
|
|
8338
|
+
...signalCode !== null && { signalName: signalCode }
|
|
8288
8339
|
});
|
|
8289
8340
|
var getOutputs = ({ state: { stdout, stderr, output }, command, start }) => ({
|
|
8290
8341
|
stdout: getOutput(stdout),
|
|
@@ -8296,11 +8347,25 @@ var getOutputs = ({ state: { stdout, stderr, output }, command, start }) => ({
|
|
|
8296
8347
|
var getOutput = (output) => output.at(-1) === "\n" ? output.slice(0, output.at(-2) === "\r" ? -2 : -1) : output;
|
|
8297
8348
|
|
|
8298
8349
|
// node_modules/nano-spawn/source/spawn.js
|
|
8350
|
+
var inspectFlagsWithValue = /* @__PURE__ */ new Set(["--inspect-port", "--inspect-publish-uid"]);
|
|
8351
|
+
var withoutInspectFlags = (arguments_) => {
|
|
8352
|
+
const result = [];
|
|
8353
|
+
for (let index = 0; index < arguments_.length; index++) {
|
|
8354
|
+
const argument = arguments_[index];
|
|
8355
|
+
if (inspectFlagsWithValue.has(argument)) {
|
|
8356
|
+
index++;
|
|
8357
|
+
} else if (!argument.startsWith("--inspect")) {
|
|
8358
|
+
result.push(argument);
|
|
8359
|
+
}
|
|
8360
|
+
}
|
|
8361
|
+
return result;
|
|
8362
|
+
};
|
|
8363
|
+
var NODE_BINARIES = process7.platform === "win32" ? ["node", "node.exe"] : ["node"];
|
|
8299
8364
|
var spawnSubprocess = async (file, commandArguments, options, context) => {
|
|
8300
8365
|
try {
|
|
8301
|
-
if (
|
|
8366
|
+
if (NODE_BINARIES.includes(process7.platform === "win32" ? file.toLowerCase() : file)) {
|
|
8302
8367
|
file = process7.execPath;
|
|
8303
|
-
commandArguments = [...process7.execArgv
|
|
8368
|
+
commandArguments = [...withoutInspectFlags(process7.execArgv), ...commandArguments];
|
|
8304
8369
|
}
|
|
8305
8370
|
[file, commandArguments, options] = await applyForceShell(file, commandArguments, options);
|
|
8306
8371
|
[file, commandArguments, options] = concatenateShell(file, commandArguments, options);
|
|
@@ -8309,7 +8374,7 @@ var spawnSubprocess = async (file, commandArguments, options, context) => {
|
|
|
8309
8374
|
bufferOutput(instance.stderr, context, "stderr");
|
|
8310
8375
|
instance.once("error", () => {
|
|
8311
8376
|
});
|
|
8312
|
-
await
|
|
8377
|
+
await once(instance, "spawn");
|
|
8313
8378
|
return instance;
|
|
8314
8379
|
} catch (error) {
|
|
8315
8380
|
throw getResultError(error, {}, context, options);
|
|
@@ -8317,40 +8382,47 @@ var spawnSubprocess = async (file, commandArguments, options, context) => {
|
|
|
8317
8382
|
};
|
|
8318
8383
|
var concatenateShell = (file, commandArguments, options) => options.shell && commandArguments.length > 0 ? [[file, ...commandArguments].join(" "), [], options] : [file, commandArguments, options];
|
|
8319
8384
|
var bufferOutput = (stream, { state }, streamName) => {
|
|
8320
|
-
if (stream) {
|
|
8321
|
-
|
|
8322
|
-
if (!state.isIterating[streamName]) {
|
|
8323
|
-
state.isIterating[streamName] = false;
|
|
8324
|
-
stream.on("data", (chunk) => {
|
|
8325
|
-
state[streamName] += chunk;
|
|
8326
|
-
state.output += chunk;
|
|
8327
|
-
});
|
|
8328
|
-
}
|
|
8385
|
+
if (!stream) {
|
|
8386
|
+
return;
|
|
8329
8387
|
}
|
|
8388
|
+
stream.setEncoding("utf8");
|
|
8389
|
+
if (state.isIterating[streamName] === true) {
|
|
8390
|
+
return;
|
|
8391
|
+
}
|
|
8392
|
+
state.isIterating[streamName] = false;
|
|
8393
|
+
stream.on("data", (chunk) => {
|
|
8394
|
+
state[streamName] += chunk;
|
|
8395
|
+
state.output += chunk;
|
|
8396
|
+
});
|
|
8330
8397
|
};
|
|
8331
8398
|
|
|
8332
8399
|
// node_modules/nano-spawn/source/pipe.js
|
|
8333
8400
|
import { pipeline } from "node:stream/promises";
|
|
8334
|
-
var handlePipe = async (subprocesses) => {
|
|
8335
|
-
const [[from, to2]] = await Promise.all([Promise.allSettled(subprocesses), pipeStreams(subprocesses)]);
|
|
8336
|
-
|
|
8337
|
-
|
|
8401
|
+
var handlePipe = async (subprocesses, context, options) => {
|
|
8402
|
+
const [[from, to2]] = await Promise.all([Promise.allSettled(subprocesses), pipeStreams(subprocesses, context, options)]);
|
|
8403
|
+
const pipedFrom = from.status === "rejected" ? from.reason : from.value;
|
|
8404
|
+
if (to2.status === "rejected") {
|
|
8405
|
+
to2.reason.pipedFrom = pipedFrom;
|
|
8338
8406
|
throw to2.reason;
|
|
8339
8407
|
}
|
|
8340
|
-
if (from.reason) {
|
|
8408
|
+
if (from.status === "rejected" && from.reason.signalName !== "SIGPIPE") {
|
|
8341
8409
|
throw from.reason;
|
|
8342
8410
|
}
|
|
8343
|
-
return { ...to2.value, pipedFrom
|
|
8411
|
+
return { ...to2.value, pipedFrom };
|
|
8344
8412
|
};
|
|
8345
|
-
var pipeStreams = async (subprocesses) => {
|
|
8413
|
+
var pipeStreams = async (subprocesses, context, options) => {
|
|
8346
8414
|
try {
|
|
8415
|
+
if (options.input !== void 0) {
|
|
8416
|
+
throw invalidOptionsError('The "input" option must not be set on the destination of ".pipe()".', context, options);
|
|
8417
|
+
}
|
|
8347
8418
|
const [{ stdout }, { stdin }] = await Promise.all(subprocesses.map(({ nodeChildProcess }) => nodeChildProcess));
|
|
8348
8419
|
if (stdin === null) {
|
|
8349
|
-
throw
|
|
8420
|
+
throw invalidOptionsError('The "stdin" option must be "pipe" on the destination of ".pipe()".', context, options);
|
|
8350
8421
|
}
|
|
8351
8422
|
if (stdout === null) {
|
|
8352
|
-
throw
|
|
8423
|
+
throw invalidOptionsError('The "stdout" option must be "pipe" on the source of ".pipe()".', context, options);
|
|
8353
8424
|
}
|
|
8425
|
+
stdout.setMaxListeners(0);
|
|
8354
8426
|
pipeline(stdout, stdin).catch(() => {
|
|
8355
8427
|
});
|
|
8356
8428
|
} catch (error) {
|
|
@@ -8358,6 +8430,12 @@ var pipeStreams = async (subprocesses) => {
|
|
|
8358
8430
|
throw error;
|
|
8359
8431
|
}
|
|
8360
8432
|
};
|
|
8433
|
+
var invalidOptionsError = (message, context, options) => getResultError(
|
|
8434
|
+
new SubprocessError(message),
|
|
8435
|
+
{},
|
|
8436
|
+
context,
|
|
8437
|
+
options
|
|
8438
|
+
);
|
|
8361
8439
|
var closeStdin = async (nodeChildProcess) => {
|
|
8362
8440
|
const { stdin } = await nodeChildProcess;
|
|
8363
8441
|
stdin.end();
|
|
@@ -8365,76 +8443,101 @@ var closeStdin = async (nodeChildProcess) => {
|
|
|
8365
8443
|
|
|
8366
8444
|
// node_modules/nano-spawn/source/iterable.js
|
|
8367
8445
|
import * as readline from "node:readline/promises";
|
|
8368
|
-
|
|
8446
|
+
import { on } from "node:events";
|
|
8447
|
+
var lineIterator = async function* (subprocess, { state }, streamName) {
|
|
8448
|
+
subprocess.catch(() => {
|
|
8449
|
+
});
|
|
8369
8450
|
if (state.isIterating[streamName] === false) {
|
|
8370
8451
|
throw new Error(`The subprocess must be iterated right away, for example:
|
|
8371
8452
|
for await (const line of spawn(...)) { ... }`);
|
|
8372
8453
|
}
|
|
8373
8454
|
state.isIterating[streamName] = true;
|
|
8374
8455
|
try {
|
|
8375
|
-
const
|
|
8456
|
+
const nodeChildProcess = await subprocess.nodeChildProcess;
|
|
8457
|
+
const stream = nodeChildProcess[streamName];
|
|
8376
8458
|
if (!stream) {
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8459
|
+
throw new NonIterableError(streamName);
|
|
8460
|
+
}
|
|
8461
|
+
const reader = readline.createInterface({ input: stream });
|
|
8462
|
+
subprocess.catch(() => reader.close());
|
|
8463
|
+
try {
|
|
8464
|
+
yield* reader;
|
|
8465
|
+
} finally {
|
|
8466
|
+
reader.close();
|
|
8467
|
+
stream.resume();
|
|
8382
8468
|
}
|
|
8383
|
-
handleErrors(subprocess);
|
|
8384
|
-
yield* readline.createInterface({ input: stream });
|
|
8385
8469
|
} finally {
|
|
8386
8470
|
await subprocess;
|
|
8387
8471
|
}
|
|
8388
8472
|
};
|
|
8389
|
-
var
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
var combineAsyncIterators = async function* ({ state }, ...iterators) {
|
|
8473
|
+
var combineAsyncIterators = async function* (...iterators) {
|
|
8474
|
+
const completions = new EventTarget();
|
|
8475
|
+
const results = on(completions, "result");
|
|
8476
|
+
const requestNext = (iterator, index) => getNext(iterator, index).then((result) => completions.dispatchEvent(new CustomEvent("result", { detail: result })));
|
|
8477
|
+
let remaining = iterators.length;
|
|
8478
|
+
const errors = [];
|
|
8396
8479
|
try {
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
const
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8480
|
+
for (const [index, iterator] of iterators.entries()) {
|
|
8481
|
+
requestNext(iterator, index);
|
|
8482
|
+
}
|
|
8483
|
+
while (remaining > 0) {
|
|
8484
|
+
const completion = await results.next();
|
|
8485
|
+
const [event] = completion.value;
|
|
8486
|
+
const { index, value, done, error } = event.detail;
|
|
8487
|
+
if (done) {
|
|
8488
|
+
remaining--;
|
|
8489
|
+
if (error !== void 0) {
|
|
8490
|
+
errors.push(error);
|
|
8491
|
+
}
|
|
8492
|
+
continue;
|
|
8406
8493
|
}
|
|
8494
|
+
yield value;
|
|
8495
|
+
requestNext(iterators[index], index);
|
|
8407
8496
|
}
|
|
8408
8497
|
} finally {
|
|
8498
|
+
await results.return();
|
|
8409
8499
|
await Promise.all(iterators.map((iterator) => iterator.return()));
|
|
8410
8500
|
}
|
|
8501
|
+
const failure = errors.find((error) => !(error instanceof NonIterableError));
|
|
8502
|
+
if (failure !== void 0) {
|
|
8503
|
+
throw failure;
|
|
8504
|
+
}
|
|
8505
|
+
if (errors.length === iterators.length) {
|
|
8506
|
+
throw new NonIterableError();
|
|
8507
|
+
}
|
|
8411
8508
|
};
|
|
8412
|
-
var getNext = async (iterator, index
|
|
8509
|
+
var getNext = async (iterator, index) => {
|
|
8413
8510
|
try {
|
|
8414
|
-
|
|
8511
|
+
const { value, done } = await iterator.next();
|
|
8512
|
+
return { index, value, done };
|
|
8415
8513
|
} catch (error) {
|
|
8416
|
-
return
|
|
8514
|
+
return { index, done: true, error };
|
|
8515
|
+
}
|
|
8516
|
+
};
|
|
8517
|
+
var NonIterableError = class extends TypeError {
|
|
8518
|
+
constructor(streamName) {
|
|
8519
|
+
const message = streamName === void 0 ? "either the option `stdout` or `stderr`" : `the option \`${streamName}\``;
|
|
8520
|
+
super(`The subprocess cannot be iterated unless ${message} is 'pipe'.`);
|
|
8417
8521
|
}
|
|
8418
8522
|
};
|
|
8419
|
-
var shouldIgnoreError = (nonIterable, index) => nonIterable.every(Boolean) ? index !== nonIterable.length - 1 : nonIterable[index];
|
|
8420
8523
|
|
|
8421
8524
|
// node_modules/nano-spawn/source/index.js
|
|
8422
8525
|
function spawn2(file, second, third, previous) {
|
|
8423
|
-
const [commandArguments
|
|
8526
|
+
const [commandArguments, options = {}] = Array.isArray(second) ? [[...second], third] : [[], second];
|
|
8424
8527
|
const context = getContext([file, ...commandArguments]);
|
|
8425
8528
|
const spawnOptions = getOptions(options);
|
|
8426
8529
|
const nodeChildProcess = spawnSubprocess(file, commandArguments, spawnOptions, context);
|
|
8427
|
-
let subprocess = getResult(nodeChildProcess, spawnOptions, context);
|
|
8530
|
+
let subprocess = getResult(nodeChildProcess, previous === void 0 ? spawnOptions : { ...spawnOptions, input: void 0 }, context);
|
|
8428
8531
|
Object.assign(subprocess, { nodeChildProcess });
|
|
8429
|
-
subprocess = previous ? handlePipe([previous, subprocess]) : subprocess;
|
|
8430
|
-
const stdout = lineIterator(subprocess, context, "stdout"
|
|
8431
|
-
const stderr = lineIterator(subprocess, context, "stderr"
|
|
8532
|
+
subprocess = previous ? handlePipe([previous, subprocess], context, spawnOptions) : subprocess;
|
|
8533
|
+
const stdout = lineIterator(subprocess, context, "stdout");
|
|
8534
|
+
const stderr = lineIterator(subprocess, context, "stderr");
|
|
8432
8535
|
return Object.assign(subprocess, {
|
|
8433
8536
|
nodeChildProcess,
|
|
8434
8537
|
stdout,
|
|
8435
8538
|
stderr,
|
|
8436
|
-
[Symbol.asyncIterator]: () => combineAsyncIterators(
|
|
8437
|
-
pipe: (
|
|
8539
|
+
[Symbol.asyncIterator]: () => combineAsyncIterators(stdout, stderr),
|
|
8540
|
+
pipe: (nextFile, nextSecond, nextThird) => spawn2(nextFile, nextSecond, nextThird, subprocess)
|
|
8438
8541
|
});
|
|
8439
8542
|
}
|
|
8440
8543
|
|