vite-plus 0.1.3 → 0.1.4

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.
@@ -1,34 +1,32 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-CgnkrU7a.js";
2
2
  import { t as lib_default } from "./lib-DxappLRQ.js";
3
3
  import { r as log, t as renderCliDoc } from "./help-BAGHa8fD.js";
4
- import path from "node:path";
5
- import { formatWithOptions, inspect, stripVTControlCharacters } from "node:util";
6
- import process$1 from "node:process";
4
+ import path, { delimiter, dirname, normalize, resolve } from "node:path";
5
+ import { formatWithOptions, inspect, promisify } from "node:util";
6
+ import { cwd } from "node:process";
7
+ import ot from "node:readline";
7
8
  import nodeTty from "node:tty";
8
9
  import { constants } from "node:fs";
9
10
  import { vitePlusHeader } from "../../binding/index.js";
10
11
  import { createRequire } from "node:module";
11
12
  import fsPromises, { constants as constants$1 } from "node:fs/promises";
12
- import { fileURLToPath, pathToFileURL } from "node:url";
13
- import { on, once } from "node:events";
14
- import { Writable } from "node:stream";
15
- import { spawn } from "node:child_process";
16
- import { pipeline } from "node:stream/promises";
17
- import * as readline from "node:readline/promises";
13
+ import { pathToFileURL } from "node:url";
14
+ import { PassThrough, Writable } from "node:stream";
15
+ import { exec, spawn } from "node:child_process";
16
+ import { createRequire as createRequire$1 } from "module";
18
17
  import * as tty from "tty";
19
18
  import { format } from "util";
20
19
  import { EOL } from "os";
21
20
  import { StringDecoder } from "string_decoder";
22
21
  import { Writable as Writable$1 } from "stream";
23
22
  import { randomUUID } from "crypto";
24
- import EventEmitter$1 from "events";
25
23
  import { EOL as EOL$1 } from "node:os";
26
24
  import crypto from "node:crypto";
27
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/colors.js
25
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/colors.js
28
26
  /**
29
27
  * @example NO_COLOR
30
- * @exmaple NO_COLOR=1
31
- * @exmaple NO_COLOR=true
28
+ * @example NO_COLOR=1
29
+ * @example NO_COLOR=true
32
30
  */
33
31
  const TRUTHRY_ENV_VAR_VALUES = [
34
32
  "",
@@ -36,8 +34,8 @@ const TRUTHRY_ENV_VAR_VALUES = [
36
34
  "true"
37
35
  ];
38
36
  /**
39
- * @exmaple FORCE_COLOR=0
40
- * @exmaple FORCE_COLOR=false
37
+ * @example FORCE_COLOR=0
38
+ * @example FORCE_COLOR=false
41
39
  */
42
40
  const FALSY_ENV_VAR_VALUES = ["0", "false"];
43
41
  /**
@@ -102,7 +100,7 @@ const blue$1 = wrapAnsiColor("\x1B[0;34m");
102
100
  const blackBright$1 = wrapAnsiColor("\x1B[0;90m");
103
101
  const bold$1 = wrapAnsiColor("\x1B[1m");
104
102
  //#endregion
105
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/debug.js
103
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/debug.js
106
104
  const format$1 = (...args) => formatWithOptions({ colors: SUPPORTS_COLOR }, ...args);
107
105
  let activeLogger;
108
106
  const enableDebug = (logger = console) => {
@@ -120,260 +118,625 @@ const createDebug = (name) => {
120
118
  };
121
119
  };
122
120
  //#endregion
123
- //#region ../../node_modules/.pnpm/nano-spawn@2.0.0/node_modules/nano-spawn/source/context.js
124
- const getContext = (raw) => ({
125
- start: process$1.hrtime.bigint(),
126
- command: raw.map((part) => getCommandPart(stripVTControlCharacters(part))).join(" "),
127
- state: {
128
- stdout: "",
129
- stderr: "",
130
- output: "",
131
- isIterating: {},
132
- nonIterable: [false, false]
121
+ //#region ../../node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.js
122
+ var l = Object.create;
123
+ var u = Object.defineProperty;
124
+ var d = Object.getOwnPropertyDescriptor;
125
+ var f = Object.getOwnPropertyNames;
126
+ var p = Object.getPrototypeOf;
127
+ var m = Object.prototype.hasOwnProperty;
128
+ var h = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
129
+ var g = (e, t, n, r) => {
130
+ if (t && typeof t === "object" || typeof t === "function") for (var i = f(t), a = 0, o = i.length, s; a < o; a++) {
131
+ s = i[a];
132
+ if (!m.call(e, s) && s !== n) u(e, s, {
133
+ get: ((e) => t[e]).bind(null, s),
134
+ enumerable: !(r = d(t, s)) || r.enumerable
135
+ });
133
136
  }
134
- });
135
- const getCommandPart = (part) => /[^\w./-]/.test(part) ? `'${part.replaceAll("'", "'\\''")}'` : part;
136
- //#endregion
137
- //#region ../../node_modules/.pnpm/nano-spawn@2.0.0/node_modules/nano-spawn/source/options.js
138
- const getOptions = ({ stdin, stdout, stderr, stdio = [
139
- stdin,
140
- stdout,
141
- stderr
142
- ], env: envOption, preferLocal, cwd: cwdOption = ".", ...options }) => {
143
- const cwd = cwdOption instanceof URL ? fileURLToPath(cwdOption) : path.resolve(cwdOption);
144
- const env = envOption ? {
145
- ...process$1.env,
146
- ...envOption
147
- } : void 0;
148
- const input = stdio[0]?.string;
149
- return {
150
- ...options,
151
- input,
152
- stdio: input === void 0 ? stdio : ["pipe", ...stdio.slice(1)],
153
- env: preferLocal ? addLocalPath(env ?? process$1.env, cwd) : env,
154
- cwd
155
- };
137
+ return e;
156
138
  };
157
- const addLocalPath = ({ Path = "", PATH = Path, ...env }, cwd) => {
158
- const pathParts = PATH.split(path.delimiter);
159
- const localPaths = getLocalPaths([], path.resolve(cwd)).map((localPath) => path.join(localPath, "node_modules/.bin")).filter((localPath) => !pathParts.includes(localPath));
139
+ var _ = (e, t, n) => (n = e != null ? l(p(e)) : {}, g(t || !e || !e.__esModule ? u(n, "default", {
140
+ value: e,
141
+ enumerable: true
142
+ }) : n, e));
143
+ var v = /* @__PURE__ */ createRequire$1(import.meta.url);
144
+ const y = /^path$/i;
145
+ const b = {
146
+ key: "PATH",
147
+ value: ""
148
+ };
149
+ function x(e) {
150
+ for (const t in e) {
151
+ if (!Object.prototype.hasOwnProperty.call(e, t) || !y.test(t)) continue;
152
+ const n = e[t];
153
+ if (!n) return b;
154
+ return {
155
+ key: t,
156
+ value: n
157
+ };
158
+ }
159
+ return b;
160
+ }
161
+ function S(e, t) {
162
+ const i = t.value.split(delimiter);
163
+ let o = e;
164
+ let s;
165
+ do {
166
+ i.push(resolve(o, "node_modules", ".bin"));
167
+ s = o;
168
+ o = dirname(o);
169
+ } while (o !== s);
160
170
  return {
161
- ...env,
162
- PATH: [...localPaths, PATH].filter(Boolean).join(path.delimiter)
171
+ key: t.key,
172
+ value: i.join(delimiter)
173
+ };
174
+ }
175
+ function C(e, t) {
176
+ const n = {
177
+ ...process.env,
178
+ ...t
163
179
  };
180
+ const r = S(e, x(n));
181
+ n[r.key] = r.value;
182
+ return n;
183
+ }
184
+ const w = (e) => {
185
+ let t = e.length;
186
+ const n = new PassThrough();
187
+ const r = () => {
188
+ if (--t === 0) n.emit("end");
189
+ };
190
+ for (const t of e) {
191
+ t.pipe(n, { end: false });
192
+ t.on("end", r);
193
+ }
194
+ return n;
164
195
  };
165
- const getLocalPaths = (localPaths, localPath) => localPaths.at(-1) === localPath ? localPaths : getLocalPaths([...localPaths, localPath], path.resolve(localPath, ".."));
166
- //#endregion
167
- //#region ../../node_modules/.pnpm/nano-spawn@2.0.0/node_modules/nano-spawn/source/windows.js
168
- const applyForceShell = async (file, commandArguments, options) => await shouldForceShell(file, options) ? [
169
- escapeFile(file),
170
- commandArguments.map((argument) => escapeArgument(argument)),
171
- {
172
- ...options,
173
- shell: true
174
- }
175
- ] : [
176
- file,
177
- commandArguments,
178
- options
179
- ];
180
- const shouldForceShell = async (file, { shell, cwd, env = process$1.env }) => process$1.platform === "win32" && !shell && !await isExe(file, cwd, env);
181
- const isExe = (file, cwd, { Path = "", PATH = Path }) => exeExtensions.some((extension) => file.toLowerCase().endsWith(extension)) || mIsExe(file, cwd, PATH);
182
- const EXE_MEMO = {};
183
- const memoize = (function_) => (...arguments_) => EXE_MEMO[arguments_.join("\0")] ??= function_(...arguments_);
184
- const access = memoize(fsPromises.access);
185
- const mIsExe = memoize(async (file, cwd, PATH) => {
186
- const parts = PATH.split(path.delimiter).filter(Boolean).map((part) => part.replace(/^"(.*)"$/, "$1"));
187
- try {
188
- await Promise.any([cwd, ...parts].flatMap((part) => exeExtensions.map((extension) => access(`${path.resolve(part, file)}${extension}`))));
189
- } catch {
196
+ var T = h((exports, t) => {
197
+ t.exports = a;
198
+ a.sync = o;
199
+ var n = v("fs");
200
+ function r(e, t) {
201
+ var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
202
+ if (!n) return true;
203
+ n = n.split(";");
204
+ if (n.indexOf("") !== -1) return true;
205
+ for (var r = 0; r < n.length; r++) {
206
+ var i = n[r].toLowerCase();
207
+ if (i && e.substr(-i.length).toLowerCase() === i) return true;
208
+ }
190
209
  return false;
191
210
  }
192
- return true;
193
- });
194
- const exeExtensions = [".exe", ".com"];
195
- const escapeArgument = (argument) => escapeFile(escapeFile(`"${argument.replaceAll(/(\\*)"/g, "$1$1\\\"").replace(/(\\*)$/, "$1$1")}"`));
196
- const escapeFile = (file) => file.replaceAll(/([()\][%!^"`<>&|;, *?])/g, "^$1");
197
- //#endregion
198
- //#region ../../node_modules/.pnpm/nano-spawn@2.0.0/node_modules/nano-spawn/source/result.js
199
- const getResult = async (nodeChildProcess, { input }, context) => {
200
- const instance = await nodeChildProcess;
201
- if (input !== void 0) instance.stdin.end(input);
202
- const onClose = once(instance, "close");
203
- try {
204
- await Promise.race([onClose, ...instance.stdio.filter(Boolean).map((stream) => onStreamError(stream))]);
205
- checkFailure(context, getErrorOutput(instance));
206
- return getOutputs(context);
207
- } catch (error) {
208
- await Promise.allSettled([onClose]);
209
- throw getResultError(error, instance, context);
211
+ function i(e, t, n) {
212
+ if (!e.isSymbolicLink() && !e.isFile()) return false;
213
+ return r(t, n);
214
+ }
215
+ function a(e, t, r) {
216
+ n.stat(e, function(n, a) {
217
+ r(n, n ? false : i(a, e, t));
218
+ });
219
+ }
220
+ function o(e, t) {
221
+ return i(n.statSync(e), e, t);
210
222
  }
211
- };
212
- const onStreamError = async (stream) => {
213
- for await (const [error] of on(stream, "error")) if (!["ERR_STREAM_PREMATURE_CLOSE", "EPIPE"].includes(error?.code)) throw error;
214
- };
215
- const checkFailure = ({ command }, { exitCode, signalName }) => {
216
- if (signalName !== void 0) throw new SubprocessError(`Command was terminated with ${signalName}: ${command}`);
217
- if (exitCode !== void 0) throw new SubprocessError(`Command failed with exit code ${exitCode}: ${command}`);
218
- };
219
- const getResultError = (error, instance, context) => Object.assign(getErrorInstance(error, context), getErrorOutput(instance), getOutputs(context));
220
- const getErrorInstance = (error, { command }) => error instanceof SubprocessError ? error : new SubprocessError(`Command failed: ${command}`, { cause: error });
221
- var SubprocessError = class extends Error {
222
- name = "SubprocessError";
223
- };
224
- const getErrorOutput = ({ exitCode, signalCode }) => ({
225
- ...exitCode < 1 ? {} : { exitCode },
226
- ...signalCode === null ? {} : { signalName: signalCode }
227
223
  });
228
- const getOutputs = ({ state: { stdout, stderr, output }, command, start }) => ({
229
- stdout: getOutput(stdout),
230
- stderr: getOutput(stderr),
231
- output: getOutput(output),
232
- command,
233
- durationMs: Number(process$1.hrtime.bigint() - start) / 1e6
224
+ var E = h((exports, t) => {
225
+ t.exports = r;
226
+ r.sync = i;
227
+ var n = v("fs");
228
+ function r(e, t, r) {
229
+ n.stat(e, function(e, n) {
230
+ r(e, e ? false : a(n, t));
231
+ });
232
+ }
233
+ function i(e, t) {
234
+ return a(n.statSync(e), t);
235
+ }
236
+ function a(e, t) {
237
+ return e.isFile() && o(e, t);
238
+ }
239
+ function o(e, t) {
240
+ var n = e.mode;
241
+ var r = e.uid;
242
+ var i = e.gid;
243
+ var a = t.uid !== void 0 ? t.uid : process.getuid && process.getuid();
244
+ var o = t.gid !== void 0 ? t.gid : process.getgid && process.getgid();
245
+ var s = parseInt("100", 8);
246
+ var c = parseInt("010", 8);
247
+ var l = parseInt("001", 8);
248
+ var u = s | c;
249
+ return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
250
+ }
234
251
  });
235
- const getOutput = (output) => output.at(-1) === "\n" ? output.slice(0, output.at(-2) === "\r" ? -2 : -1) : output;
236
- //#endregion
237
- //#region ../../node_modules/.pnpm/nano-spawn@2.0.0/node_modules/nano-spawn/source/spawn.js
238
- const spawnSubprocess = async (file, commandArguments, options, context) => {
239
- try {
240
- if (["node", "node.exe"].includes(file.toLowerCase())) {
241
- file = process$1.execPath;
242
- commandArguments = [...process$1.execArgv.filter((flag) => !flag.startsWith("--inspect")), ...commandArguments];
252
+ var D = h((exports, t) => {
253
+ v("fs");
254
+ var r;
255
+ if (process.platform === "win32" || global.TESTING_WINDOWS) r = T();
256
+ else r = E();
257
+ t.exports = i;
258
+ i.sync = a;
259
+ function i(e, t, n) {
260
+ if (typeof t === "function") {
261
+ n = t;
262
+ t = {};
243
263
  }
244
- [file, commandArguments, options] = await applyForceShell(file, commandArguments, options);
245
- [file, commandArguments, options] = concatenateShell(file, commandArguments, options);
246
- const instance = spawn(file, commandArguments, options);
247
- bufferOutput(instance.stdout, context, "stdout");
248
- bufferOutput(instance.stderr, context, "stderr");
249
- instance.once("error", () => {});
250
- await once(instance, "spawn");
251
- return instance;
252
- } catch (error) {
253
- throw getResultError(error, {}, context);
264
+ if (!n) {
265
+ if (typeof Promise !== "function") throw new TypeError("callback not provided");
266
+ return new Promise(function(n, r) {
267
+ i(e, t || {}, function(e, t) {
268
+ if (e) r(e);
269
+ else n(t);
270
+ });
271
+ });
272
+ }
273
+ r(e, t || {}, function(e, r) {
274
+ if (e) {
275
+ if (e.code === "EACCES" || t && t.ignoreErrors) {
276
+ e = null;
277
+ r = false;
278
+ }
279
+ }
280
+ n(e, r);
281
+ });
254
282
  }
255
- };
256
- const concatenateShell = (file, commandArguments, options) => options.shell && commandArguments.length > 0 ? [
257
- [file, ...commandArguments].join(" "),
258
- [],
259
- options
260
- ] : [
261
- file,
262
- commandArguments,
263
- options
264
- ];
265
- const bufferOutput = (stream, { state }, streamName) => {
266
- if (stream) {
267
- stream.setEncoding("utf8");
268
- if (!state.isIterating[streamName]) {
269
- state.isIterating[streamName] = false;
270
- stream.on("data", (chunk) => {
271
- state[streamName] += chunk;
272
- state.output += chunk;
283
+ function a(e, t) {
284
+ try {
285
+ return r.sync(e, t || {});
286
+ } catch (e) {
287
+ if (t && t.ignoreErrors || e.code === "EACCES") return false;
288
+ else throw e;
289
+ }
290
+ }
291
+ });
292
+ var O = h((exports, t) => {
293
+ const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
294
+ const r = v("path");
295
+ const i = n ? ";" : ":";
296
+ const a = D();
297
+ const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" });
298
+ const s = (e, t) => {
299
+ const r = t.colon || i;
300
+ const a = e.match(/\//) || n && e.match(/\\/) ? [""] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || "").split(r)];
301
+ const o = n ? t.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
302
+ const s = n ? o.split(r) : [""];
303
+ if (n) {
304
+ if (e.indexOf(".") !== -1 && s[0] !== "") s.unshift("");
305
+ }
306
+ return {
307
+ pathEnv: a,
308
+ pathExt: s,
309
+ pathExtExe: o
310
+ };
311
+ };
312
+ const c = (e, t, n) => {
313
+ if (typeof t === "function") {
314
+ n = t;
315
+ t = {};
316
+ }
317
+ if (!t) t = {};
318
+ const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t);
319
+ const u = [];
320
+ const d = (n) => new Promise((a, s) => {
321
+ if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
322
+ const c = i[n];
323
+ const l = /^".*"$/.test(c) ? c.slice(1, -1) : c;
324
+ const d = r.join(l, e);
325
+ a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
326
+ });
327
+ const f = (e, n, r) => new Promise((i, o) => {
328
+ if (r === c.length) return i(d(n + 1));
329
+ const s = c[r];
330
+ a(e + s, { pathExt: l }, (a, o) => {
331
+ if (!a && o) if (t.all) u.push(e + s);
332
+ else return i(e + s);
333
+ return i(f(e, n, r + 1));
334
+ });
335
+ });
336
+ return n ? d(0).then((e) => n(null, e), n) : d(0);
337
+ };
338
+ const l = (e, t) => {
339
+ t = t || {};
340
+ const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t);
341
+ const l = [];
342
+ for (let o = 0; o < n.length; o++) {
343
+ const s = n[o];
344
+ const u = /^".*"$/.test(s) ? s.slice(1, -1) : s;
345
+ const d = r.join(u, e);
346
+ const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
347
+ for (let e = 0; e < i.length; e++) {
348
+ const n = f + i[e];
349
+ try {
350
+ if (a.sync(n, { pathExt: c })) if (t.all) l.push(n);
351
+ else return n;
352
+ } catch (e) {}
353
+ }
354
+ }
355
+ if (t.all && l.length) return l;
356
+ if (t.nothrow) return null;
357
+ throw o(e);
358
+ };
359
+ t.exports = c;
360
+ c.sync = l;
361
+ });
362
+ var k = h((exports, t) => {
363
+ const n = (e = {}) => {
364
+ const t = e.env || process.env;
365
+ if ((e.platform || process.platform) !== "win32") return "PATH";
366
+ return Object.keys(t).reverse().find((e) => e.toUpperCase() === "PATH") || "Path";
367
+ };
368
+ t.exports = n;
369
+ t.exports.default = n;
370
+ });
371
+ var A = h((exports, t) => {
372
+ const n = v("path");
373
+ const r = O();
374
+ const i = k();
375
+ function a(e, t) {
376
+ const a = e.options.env || process.env;
377
+ const o = process.cwd();
378
+ const s = e.options.cwd != null;
379
+ const c = s && process.chdir !== void 0 && !process.chdir.disabled;
380
+ if (c) try {
381
+ process.chdir(e.options.cwd);
382
+ } catch (e) {}
383
+ let l;
384
+ try {
385
+ l = r.sync(e.command, {
386
+ path: a[i({ env: a })],
387
+ pathExt: t ? n.delimiter : void 0
273
388
  });
389
+ } catch (e) {} finally {
390
+ if (c) process.chdir(o);
274
391
  }
392
+ if (l) l = n.resolve(s ? e.options.cwd : "", l);
393
+ return l;
275
394
  }
276
- };
277
- //#endregion
278
- //#region ../../node_modules/.pnpm/nano-spawn@2.0.0/node_modules/nano-spawn/source/pipe.js
279
- const handlePipe = async (subprocesses) => {
280
- const [[from, to]] = await Promise.all([Promise.allSettled(subprocesses), pipeStreams(subprocesses)]);
281
- if (to.reason) {
282
- to.reason.pipedFrom = from.reason ?? from.value;
283
- throw to.reason;
284
- }
285
- if (from.reason) throw from.reason;
286
- return {
287
- ...to.value,
288
- pipedFrom: from.value
395
+ function o(e) {
396
+ return a(e) || a(e, true);
397
+ }
398
+ t.exports = o;
399
+ });
400
+ var j = h((exports, t) => {
401
+ const n = /([()\][%!^"`<>&|;, *?])/g;
402
+ function r(e) {
403
+ e = e.replace(n, "^$1");
404
+ return e;
405
+ }
406
+ function i(e, t) {
407
+ e = `${e}`;
408
+ e = e.replace(/(\\*)"/g, "$1$1\\\"");
409
+ e = e.replace(/(\\*)$/, "$1$1");
410
+ e = `"${e}"`;
411
+ e = e.replace(n, "^$1");
412
+ if (t) e = e.replace(n, "^$1");
413
+ return e;
414
+ }
415
+ t.exports.command = r;
416
+ t.exports.argument = i;
417
+ });
418
+ var M = h((exports, t) => {
419
+ t.exports = /^#!(.*)/;
420
+ });
421
+ var N = h((exports, t) => {
422
+ const n = M();
423
+ t.exports = (e = "") => {
424
+ const t = e.match(n);
425
+ if (!t) return null;
426
+ const [r, i] = t[0].replace(/#! ?/, "").split(" ");
427
+ const a = r.split("/").pop();
428
+ if (a === "env") return i;
429
+ return i ? `${a} ${i}` : a;
289
430
  };
290
- };
291
- const pipeStreams = async (subprocesses) => {
292
- try {
293
- const [{ stdout }, { stdin }] = await Promise.all(subprocesses.map(({ nodeChildProcess }) => nodeChildProcess));
294
- if (stdin === null) throw new Error("The \"stdin\" option must be set on the first \"spawn()\" call in the pipeline.");
295
- if (stdout === null) throw new Error("The \"stdout\" option must be set on the last \"spawn()\" call in the pipeline.");
296
- pipeline(stdout, stdin).catch(() => {});
297
- } catch (error) {
298
- await Promise.allSettled(subprocesses.map(({ nodeChildProcess }) => closeStdin(nodeChildProcess)));
299
- throw error;
431
+ });
432
+ var P = h((exports, t) => {
433
+ const n = v("fs");
434
+ const r = N();
435
+ function i(e) {
436
+ const t = 150;
437
+ const i = Buffer.alloc(t);
438
+ let a;
439
+ try {
440
+ a = n.openSync(e, "r");
441
+ n.readSync(a, i, 0, t, 0);
442
+ n.closeSync(a);
443
+ } catch (e) {}
444
+ return r(i.toString());
300
445
  }
301
- };
302
- const closeStdin = async (nodeChildProcess) => {
303
- const { stdin } = await nodeChildProcess;
304
- stdin.end();
305
- };
306
- //#endregion
307
- //#region ../../node_modules/.pnpm/nano-spawn@2.0.0/node_modules/nano-spawn/source/iterable.js
308
- const lineIterator = async function* (subprocess, { state }, streamName, index) {
309
- if (state.isIterating[streamName] === false) throw new Error(`The subprocess must be iterated right away, for example:
310
- for await (const line of spawn(...)) { ... }`);
311
- state.isIterating[streamName] = true;
312
- try {
313
- const { [streamName]: stream } = await subprocess.nodeChildProcess;
314
- if (!stream) {
315
- state.nonIterable[index] = true;
316
- const message = state.nonIterable.every(Boolean) ? "either the option `stdout` or `stderr`" : `the option \`${streamName}\``;
317
- throw new TypeError(`The subprocess cannot be iterated unless ${message} is 'pipe'.`);
446
+ t.exports = i;
447
+ });
448
+ var F = h((exports, t) => {
449
+ const n = v("path");
450
+ const r = A();
451
+ const i = j();
452
+ const a = P();
453
+ const o = process.platform === "win32";
454
+ const s = /\.(?:com|exe)$/i;
455
+ const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
456
+ function l(e) {
457
+ e.file = r(e);
458
+ const t = e.file && a(e.file);
459
+ if (t) {
460
+ e.args.unshift(e.file);
461
+ e.command = t;
462
+ return r(e);
463
+ }
464
+ return e.file;
465
+ }
466
+ function u(e) {
467
+ if (!o) return e;
468
+ const t = l(e);
469
+ const r = !s.test(t);
470
+ if (e.options.forceShell || r) {
471
+ const r = c.test(t);
472
+ e.command = n.normalize(e.command);
473
+ e.command = i.command(e.command);
474
+ e.args = e.args.map((e) => i.argument(e, r));
475
+ e.args = [
476
+ "/d",
477
+ "/s",
478
+ "/c",
479
+ `"${[e.command].concat(e.args).join(" ")}"`
480
+ ];
481
+ e.command = process.env.comspec || "cmd.exe";
482
+ e.options.windowsVerbatimArguments = true;
318
483
  }
319
- handleErrors(subprocess);
320
- yield* readline.createInterface({ input: stream });
321
- } finally {
322
- await subprocess;
484
+ return e;
485
+ }
486
+ function d(e, t, n) {
487
+ if (t && !Array.isArray(t)) {
488
+ n = t;
489
+ t = null;
490
+ }
491
+ t = t ? t.slice(0) : [];
492
+ n = Object.assign({}, n);
493
+ const r = {
494
+ command: e,
495
+ args: t,
496
+ options: n,
497
+ file: void 0,
498
+ original: {
499
+ command: e,
500
+ args: t
501
+ }
502
+ };
503
+ return n.shell ? r : u(r);
504
+ }
505
+ t.exports = d;
506
+ });
507
+ var I = h((exports, t) => {
508
+ const n = process.platform === "win32";
509
+ function r(e, t) {
510
+ return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
511
+ code: "ENOENT",
512
+ errno: "ENOENT",
513
+ syscall: `${t} ${e.command}`,
514
+ path: e.command,
515
+ spawnargs: e.args
516
+ });
517
+ }
518
+ function i(e, t) {
519
+ if (!n) return;
520
+ const r = e.emit;
521
+ e.emit = function(n, i) {
522
+ if (n === "exit") {
523
+ const n = a(i, t, "spawn");
524
+ if (n) return r.call(e, "error", n);
525
+ }
526
+ return r.apply(e, arguments);
527
+ };
528
+ }
529
+ function a(e, t) {
530
+ if (n && e === 1 && !t.file) return r(t.original, "spawn");
531
+ return null;
532
+ }
533
+ function o(e, t) {
534
+ if (n && e === 1 && !t.file) return r(t.original, "spawnSync");
535
+ return null;
536
+ }
537
+ t.exports = {
538
+ hookChildProcess: i,
539
+ verifyENOENT: a,
540
+ verifyENOENTSync: o,
541
+ notFoundError: r
542
+ };
543
+ });
544
+ var R = _(h((exports, t) => {
545
+ const n = v("child_process");
546
+ const r = F();
547
+ const i = I();
548
+ function a(e, t, a) {
549
+ const o = r(e, t, a);
550
+ const s = n.spawn(o.command, o.args, o.options);
551
+ i.hookChildProcess(s, o);
552
+ return s;
553
+ }
554
+ function o(e, t, a) {
555
+ const o = r(e, t, a);
556
+ const s = n.spawnSync(o.command, o.args, o.options);
557
+ s.error = s.error || i.verifyENOENTSync(s.status, o);
558
+ return s;
559
+ }
560
+ t.exports = a;
561
+ t.exports.spawn = a;
562
+ t.exports.sync = o;
563
+ t.exports._parse = r;
564
+ t.exports._enoent = i;
565
+ })(), 1);
566
+ var z = class extends Error {
567
+ result;
568
+ output;
569
+ get exitCode() {
570
+ if (this.result.exitCode !== null) return this.result.exitCode;
571
+ }
572
+ constructor(e, t) {
573
+ super(`Process exited with non-zero status (${e.exitCode})`);
574
+ this.result = e;
575
+ this.output = t;
323
576
  }
324
577
  };
325
- const handleErrors = async (subprocess) => {
326
- try {
327
- await subprocess;
328
- } catch {}
578
+ const B = {
579
+ timeout: void 0,
580
+ persist: false
329
581
  };
330
- const combineAsyncIterators = async function* ({ state }, ...iterators) {
331
- try {
332
- let promises = [];
333
- while (iterators.length > 0) {
334
- promises = iterators.map((iterator, index) => promises[index] ?? getNext(iterator, index, state));
335
- const [{ value, done }, index] = await Promise.race(promises.map((promise, index) => Promise.all([promise, index])));
336
- const [iterator] = iterators.splice(index, 1);
337
- promises.splice(index, 1);
338
- if (!done) {
339
- iterators.push(iterator);
340
- yield value;
341
- }
582
+ const V = { windowsHide: true };
583
+ function H(e, t) {
584
+ return {
585
+ command: normalize(e),
586
+ args: t ?? []
587
+ };
588
+ }
589
+ function U(e) {
590
+ const t = new AbortController();
591
+ for (const n of e) {
592
+ if (n.aborted) {
593
+ t.abort();
594
+ return n;
342
595
  }
343
- } finally {
344
- await Promise.all(iterators.map((iterator) => iterator.return()));
596
+ const e = () => {
597
+ t.abort(n.reason);
598
+ };
599
+ n.addEventListener("abort", e, { signal: t.signal });
345
600
  }
346
- };
347
- const getNext = async (iterator, index, { nonIterable }) => {
348
- try {
349
- return await iterator.next();
350
- } catch (error) {
351
- return shouldIgnoreError(nonIterable, index) ? iterator.return() : iterator.throw(error);
601
+ return t.signal;
602
+ }
603
+ async function W(e) {
604
+ let t = "";
605
+ for await (const n of e) t += n.toString();
606
+ return t;
607
+ }
608
+ var G = class {
609
+ _process;
610
+ _aborted = false;
611
+ _options;
612
+ _command;
613
+ _args;
614
+ _resolveClose;
615
+ _processClosed;
616
+ _thrownError;
617
+ get process() {
618
+ return this._process;
619
+ }
620
+ get pid() {
621
+ return this._process?.pid;
622
+ }
623
+ get exitCode() {
624
+ if (this._process && this._process.exitCode !== null) return this._process.exitCode;
625
+ }
626
+ constructor(e, t, n) {
627
+ this._options = {
628
+ ...B,
629
+ ...n
630
+ };
631
+ this._command = e;
632
+ this._args = t ?? [];
633
+ this._processClosed = new Promise((e) => {
634
+ this._resolveClose = e;
635
+ });
636
+ }
637
+ kill(e) {
638
+ return this._process?.kill(e) === true;
639
+ }
640
+ get aborted() {
641
+ return this._aborted;
642
+ }
643
+ get killed() {
644
+ return this._process?.killed === true;
645
+ }
646
+ pipe(e, t, n) {
647
+ return q(e, t, {
648
+ ...n,
649
+ stdin: this
650
+ });
651
+ }
652
+ async *[Symbol.asyncIterator]() {
653
+ const e = this._process;
654
+ if (!e) return;
655
+ const t = [];
656
+ if (this._streamErr) t.push(this._streamErr);
657
+ if (this._streamOut) t.push(this._streamOut);
658
+ const n = w(t);
659
+ const r = ot.createInterface({ input: n });
660
+ for await (const e of r) yield e.toString();
661
+ await this._processClosed;
662
+ e.removeAllListeners();
663
+ if (this._thrownError) throw this._thrownError;
664
+ if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this);
665
+ }
666
+ async _waitForOutput() {
667
+ const e = this._process;
668
+ if (!e) throw new Error("No process was started");
669
+ const [t, n] = await Promise.all([this._streamOut ? W(this._streamOut) : "", this._streamErr ? W(this._streamErr) : ""]);
670
+ await this._processClosed;
671
+ if (this._options?.stdin) await this._options.stdin;
672
+ e.removeAllListeners();
673
+ if (this._thrownError) throw this._thrownError;
674
+ const r = {
675
+ stderr: n,
676
+ stdout: t,
677
+ exitCode: this.exitCode
678
+ };
679
+ if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this, r);
680
+ return r;
681
+ }
682
+ then(e, t) {
683
+ return this._waitForOutput().then(e, t);
684
+ }
685
+ _streamOut;
686
+ _streamErr;
687
+ spawn() {
688
+ const e = cwd();
689
+ const n = this._options;
690
+ const r = {
691
+ ...V,
692
+ ...n.nodeOptions
693
+ };
694
+ const i = [];
695
+ this._resetState();
696
+ if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout));
697
+ if (n.signal !== void 0) i.push(n.signal);
698
+ if (n.persist === true) r.detached = true;
699
+ if (i.length > 0) r.signal = U(i);
700
+ r.env = C(e, r.env);
701
+ const { command: a, args: s } = H(this._command, this._args);
702
+ const c = (0, R._parse)(a, s, r);
703
+ const l = spawn(c.command, c.args, c.options);
704
+ if (l.stderr) this._streamErr = l.stderr;
705
+ if (l.stdout) this._streamOut = l.stdout;
706
+ this._process = l;
707
+ l.once("error", this._onError);
708
+ l.once("close", this._onClose);
709
+ if (n.stdin !== void 0 && l.stdin && n.stdin.process) {
710
+ const { stdout: e } = n.stdin.process;
711
+ if (e) e.pipe(l.stdin);
712
+ }
713
+ }
714
+ _resetState() {
715
+ this._aborted = false;
716
+ this._processClosed = new Promise((e) => {
717
+ this._resolveClose = e;
718
+ });
719
+ this._thrownError = void 0;
352
720
  }
721
+ _onError = (e) => {
722
+ if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
723
+ this._aborted = true;
724
+ return;
725
+ }
726
+ this._thrownError = e;
727
+ };
728
+ _onClose = () => {
729
+ if (this._resolveClose) this._resolveClose();
730
+ };
353
731
  };
354
- const shouldIgnoreError = (nonIterable, index) => nonIterable.every(Boolean) ? index !== nonIterable.length - 1 : nonIterable[index];
355
- //#endregion
356
- //#region ../../node_modules/.pnpm/nano-spawn@2.0.0/node_modules/nano-spawn/source/index.js
357
- function spawn$2(file, second, third, previous) {
358
- const [commandArguments = [], options = {}] = Array.isArray(second) ? [second, third] : [[], second];
359
- const context = getContext([file, ...commandArguments]);
360
- const spawnOptions = getOptions(options);
361
- const nodeChildProcess = spawnSubprocess(file, commandArguments, spawnOptions, context);
362
- let subprocess = getResult(nodeChildProcess, spawnOptions, context);
363
- Object.assign(subprocess, { nodeChildProcess });
364
- subprocess = previous ? handlePipe([previous, subprocess]) : subprocess;
365
- const stdout = lineIterator(subprocess, context, "stdout", 0);
366
- const stderr = lineIterator(subprocess, context, "stderr", 1);
367
- return Object.assign(subprocess, {
368
- nodeChildProcess,
369
- stdout,
370
- stderr,
371
- [Symbol.asyncIterator]: () => combineAsyncIterators(context, stdout, stderr),
372
- pipe: (file, second, third) => spawn$2(file, second, third, subprocess)
373
- });
374
- }
732
+ const K = (e, t, n) => {
733
+ const r = new G(e, t, n);
734
+ r.spawn();
735
+ return r;
736
+ };
737
+ const q = K;
375
738
  //#endregion
376
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/execGit.js
739
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/execGit.js
377
740
  const debugLog$15 = createDebug("lint-staged:execGit");
378
741
  /**
379
742
  * Explicitly never recurse commands into submodules, overriding local/global configuration.
@@ -381,19 +744,18 @@ const debugLog$15 = createDebug("lint-staged:execGit");
381
744
  */
382
745
  const NO_SUBMODULE_RECURSE = ["-c", "submodule.recurse=false"];
383
746
  [...NO_SUBMODULE_RECURSE];
384
- /** @type {(cmd: string[], options?: import('nano-spawn').Options) => Promise<string>} */
747
+ /** @type {(cmd: string[], options?: { cwd?: string }) => Promise<string>} */
385
748
  const execGit = async (cmd, options) => {
386
- debugLog$15("Running git command", cmd);
387
- try {
388
- return (await spawn$2("git", [...NO_SUBMODULE_RECURSE, ...cmd], {
389
- ...options,
390
- cwd: options?.cwd ?? process.cwd(),
391
- stdin: "ignore"
392
- })).stdout;
393
- } catch (error) {
394
- if (error instanceof SubprocessError) throw new Error(error.output, { cause: error });
395
- throw error;
396
- }
749
+ debugLog$15("Running git command:", cmd);
750
+ const result = q("git", [...NO_SUBMODULE_RECURSE, ...cmd], { nodeOptions: {
751
+ cwd: options?.cwd,
752
+ stdio: ["ignore"]
753
+ } });
754
+ let output = "";
755
+ for await (const line of result) output += line + "\n";
756
+ output = output.trimEnd();
757
+ if (result.exitCode > 0) throw new Error(output, { cause: result });
758
+ return output;
397
759
  };
398
760
  var eventemitter3_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
399
761
  var has = Object.prototype.hasOwnProperty, prefix = "~";
@@ -2726,12 +3088,12 @@ var Listr = class {
2726
3088
  }
2727
3089
  };
2728
3090
  //#endregion
2729
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/figures.js
3091
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/figures.js
2730
3092
  const info = blue$1(figures.arrowRight);
2731
3093
  const error = red$1(figures.cross);
2732
3094
  const warning = yellow$1(figures.warning);
2733
3095
  //#endregion
2734
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/messages.js
3096
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/messages.js
2735
3097
  const configurationError = (opt, helpMsg, value) => `${red$1(`${error} Validation Error:`)}
2736
3098
 
2737
3099
  Invalid value for '${bold$1(opt)}': ${bold$1(inspect(value))}
@@ -2750,7 +3112,7 @@ const skippingBackup = (hasInitialCommit, diff) => {
2750
3112
  const SKIPPING_HIDE_PARTIALLY_CHANGED = yellow$1(`${warning} Skipping hiding unstaged changes from partially staged files because \`--no-hide-partially-staged\` was used.\n`);
2751
3113
  const DEPRECATED_GIT_ADD = yellow$1(`${warning} Some of your tasks use \`git add\` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.
2752
3114
  `);
2753
- const TASK_ERROR$1 = "Skipped because of errors from tasks.";
3115
+ const TASK_ERROR = "Skipped because of errors from tasks.";
2754
3116
  const PREVENTED_TASK_MODIFICATIONS = `\n${error} lint-staged failed because \`--fail-on-changes\` was used.`;
2755
3117
  const SKIPPED_GIT_ERROR = "Skipped because of previous git error.";
2756
3118
  const GIT_ERROR = `\n ${red$1(`${error} lint-staged failed due to a git error.`)}`;
@@ -2779,7 +3141,7 @@ ${error}
2779
3141
  See https://github.com/okonet/lint-staged#configuration.`;
2780
3142
  const UNSTAGED_CHANGES_BACKUP_STASH_LOCATION = `Unstaged changes have been kept back in a patch file:`;
2781
3143
  //#endregion
2782
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/printTaskOutput.js
3144
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/printTaskOutput.js
2783
3145
  /**
2784
3146
  * Handle logging of listr `ctx.output` to the specified `logger`
2785
3147
  * @param {Object} ctx - The listr initial state
@@ -2791,7 +3153,7 @@ const printTaskOutput = (ctx = {}, logger) => {
2791
3153
  for (const line of ctx.output) log(line);
2792
3154
  };
2793
3155
  //#endregion
2794
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/normalizePath.js
3156
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/normalizePath.js
2795
3157
  /**
2796
3158
  * Reimplementation of "normalize-path"
2797
3159
  * @see https://github.com/jonschlinkert/normalize-path/blob/52c3a95ebebc2d98c1ad7606cbafa7e658656899/index.js
@@ -2827,7 +3189,7 @@ const normalizePath = (input) => {
2827
3189
  return normalized;
2828
3190
  };
2829
3191
  //#endregion
2830
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/chunkFiles.js
3192
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/chunkFiles.js
2831
3193
  const debugLog$14 = createDebug("lint-staged:chunkFiles");
2832
3194
  /**
2833
3195
  * Chunk array into sub-arrays
@@ -5604,7 +5966,7 @@ var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5604
5966
  module.exports = require_picomatch$1();
5605
5967
  }));
5606
5968
  //#endregion
5607
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/generateTasks.js
5969
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/generateTasks.js
5608
5970
  var import_micromatch = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
5609
5971
  const util = __require("util");
5610
5972
  const braces = require_braces();
@@ -6040,280 +6402,24 @@ const generateTasks = ({ config, cwd = process.cwd(), files, relative = false })
6040
6402
  });
6041
6403
  };
6042
6404
  //#endregion
6043
- //#region ../../node_modules/.pnpm/pidtree@0.6.0/node_modules/pidtree/lib/bin.js
6044
- var require_bin = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6045
- var spawn$1 = __require("child_process").spawn;
6046
- function stripStderr(stderr) {
6047
- if (!stderr) return;
6048
- stderr = stderr.trim();
6049
- stderr = stderr.replace(/your \d+x\d+ screen size is bogus\. expect trouble/gi, "");
6050
- return stderr.trim();
6051
- }
6052
- /**
6053
- * Spawn a binary and read its stdout.
6054
- * @param {String} cmd The name of the binary to spawn.
6055
- * @param {String[]} args The arguments for the binary.
6056
- * @param {Object} [options] Optional option for the spawn function.
6057
- * @param {Function} done(err, stdout)
6058
- */
6059
- function run(cmd, args, options, done) {
6060
- if (typeof options === "function") {
6061
- done = options;
6062
- options = void 0;
6063
- }
6064
- var executed = false;
6065
- var ch = spawn$1(cmd, args, options);
6066
- var stdout = "";
6067
- var stderr = "";
6068
- ch.stdout.on("data", function(d) {
6069
- stdout += d.toString();
6070
- });
6071
- ch.stderr.on("data", function(d) {
6072
- stderr += d.toString();
6073
- });
6074
- ch.on("error", function(err) {
6075
- if (executed) return;
6076
- executed = true;
6077
- done(new Error(err));
6078
- });
6079
- ch.on("close", function(code) {
6080
- if (executed) return;
6081
- executed = true;
6082
- stderr = stripStderr(stderr);
6083
- if (stderr) return done(new Error(stderr));
6084
- done(null, stdout, code);
6085
- });
6086
- }
6087
- module.exports = run;
6088
- }));
6089
- //#endregion
6090
- //#region ../../node_modules/.pnpm/pidtree@0.6.0/node_modules/pidtree/lib/ps.js
6091
- var require_ps = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6092
- var os$2 = __require("os");
6093
- var bin = require_bin();
6094
- /**
6095
- * Gets the list of all the pids of the system through the ps command.
6096
- * @param {Function} callback(err, list)
6097
- */
6098
- function ps(callback) {
6099
- bin("ps", [
6100
- "-A",
6101
- "-o",
6102
- "ppid,pid"
6103
- ], function(err, stdout, code) {
6104
- if (err) return callback(err);
6105
- if (code !== 0) return callback(/* @__PURE__ */ new Error("pidtree ps command exited with code " + code));
6106
- try {
6107
- stdout = stdout.split(os$2.EOL);
6108
- var list = [];
6109
- for (var i = 1; i < stdout.length; i++) {
6110
- stdout[i] = stdout[i].trim();
6111
- if (!stdout[i]) continue;
6112
- stdout[i] = stdout[i].split(/\s+/);
6113
- stdout[i][0] = parseInt(stdout[i][0], 10);
6114
- stdout[i][1] = parseInt(stdout[i][1], 10);
6115
- list.push(stdout[i]);
6116
- }
6117
- callback(null, list);
6118
- } catch (error) {
6119
- callback(error);
6120
- }
6121
- });
6122
- }
6123
- module.exports = ps;
6124
- }));
6125
- //#endregion
6126
- //#region ../../node_modules/.pnpm/pidtree@0.6.0/node_modules/pidtree/lib/wmic.js
6127
- var require_wmic = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6128
- var os$1 = __require("os");
6129
- var bin = require_bin();
6130
- /**
6131
- * Gets the list of all the pids of the system through the wmic command.
6132
- * @param {Function} callback(err, list)
6133
- */
6134
- function wmic(callback) {
6135
- bin("wmic", [
6136
- "PROCESS",
6137
- "get",
6138
- "ParentProcessId,ProcessId"
6139
- ], {
6140
- windowsHide: true,
6141
- windowsVerbatimArguments: true
6142
- }, function(err, stdout, code) {
6143
- if (err) {
6144
- callback(err);
6145
- return;
6146
- }
6147
- if (code !== 0) {
6148
- callback(/* @__PURE__ */ new Error("pidtree wmic command exited with code " + code));
6149
- return;
6150
- }
6151
- try {
6152
- stdout = stdout.split(os$1.EOL);
6153
- var list = [];
6154
- for (var i = 1; i < stdout.length; i++) {
6155
- stdout[i] = stdout[i].trim();
6156
- if (!stdout[i]) continue;
6157
- stdout[i] = stdout[i].split(/\s+/);
6158
- stdout[i][0] = parseInt(stdout[i][0], 10);
6159
- stdout[i][1] = parseInt(stdout[i][1], 10);
6160
- list.push(stdout[i]);
6161
- }
6162
- callback(null, list);
6163
- } catch (error) {
6164
- callback(error);
6165
- }
6166
- });
6167
- }
6168
- module.exports = wmic;
6169
- }));
6170
- //#endregion
6171
- //#region ../../node_modules/.pnpm/pidtree@0.6.0/node_modules/pidtree/lib/get.js
6172
- var require_get = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6173
- var os = __require("os");
6174
- var platformToMethod = {
6175
- darwin: "ps",
6176
- sunos: "ps",
6177
- freebsd: "ps",
6178
- netbsd: "ps",
6179
- win: "wmic",
6180
- linux: "ps",
6181
- aix: "ps"
6182
- };
6183
- var methodToRequireFn = {
6184
- ps: () => require_ps(),
6185
- wmic: () => require_wmic()
6186
- };
6187
- var platform = os.platform();
6188
- if (platform.startsWith("win")) platform = "win";
6189
- var method = platformToMethod[platform];
6190
- /**
6191
- * Gets the list of all the pids of the system.
6192
- * @param {Function} callback Called when the list is ready.
6193
- */
6194
- function get(callback) {
6195
- if (method === void 0) callback(/* @__PURE__ */ new Error(os.platform() + " is not supported yet, please open an issue (https://github.com/simonepri/pidtree)"));
6196
- methodToRequireFn[method]()(callback);
6197
- }
6198
- module.exports = get;
6199
- }));
6200
- //#endregion
6201
- //#region ../../node_modules/.pnpm/pidtree@0.6.0/node_modules/pidtree/lib/pidtree.js
6202
- var require_pidtree$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6203
- var getAll = require_get();
6204
- /**
6205
- * Get the list of children and grandchildren pids of the given PID.
6206
- * @param {Number|String} PID A PID. If -1 will return all the pids.
6207
- * @param {Object} [options] Optional options object.
6208
- * @param {Boolean} [options.root=false] Include the provided PID in the list.
6209
- * @param {Boolean} [options.advanced=false] Returns a list of objects in the
6210
- * format {pid: X, ppid: Y}.
6211
- * @param {Function} callback(err, list) Called when the list is ready.
6212
- */
6213
- function list(PID, options, callback) {
6214
- if (typeof options === "function") {
6215
- callback = options;
6216
- options = {};
6217
- }
6218
- if (typeof options !== "object") options = {};
6219
- PID = parseInt(PID, 10);
6220
- if (isNaN(PID) || PID < -1) {
6221
- callback(/* @__PURE__ */ new TypeError("The pid provided is invalid"));
6222
- return;
6223
- }
6224
- getAll(function(err, list) {
6225
- if (err) {
6226
- callback(err);
6227
- return;
6228
- }
6229
- if (PID === -1) {
6230
- for (var i = 0; i < list.length; i++) list[i] = options.advanced ? {
6231
- ppid: list[i][0],
6232
- pid: list[i][1]
6233
- } : list[i] = list[i][1];
6234
- callback(null, list);
6235
- return;
6236
- }
6237
- var root;
6238
- for (var l = 0; l < list.length; l++) {
6239
- if (list[l][1] === PID) {
6240
- root = options.advanced ? {
6241
- ppid: list[l][0],
6242
- pid: PID
6243
- } : PID;
6244
- break;
6245
- }
6246
- if (list[l][0] === PID) root = options.advanced ? { pid: PID } : PID;
6247
- }
6248
- if (!root) {
6249
- callback(/* @__PURE__ */ new Error("No matching pid found"));
6250
- return;
6251
- }
6252
- var tree = {};
6253
- while (list.length > 0) {
6254
- var element = list.pop();
6255
- if (tree[element[0]]) tree[element[0]].push(element[1]);
6256
- else tree[element[0]] = [element[1]];
6257
- }
6258
- var idx = 0;
6259
- var pids = [root];
6260
- while (idx < pids.length) {
6261
- var curpid = options.advanced ? pids[idx++].pid : pids[idx++];
6262
- if (!tree[curpid]) continue;
6263
- var length = tree[curpid].length;
6264
- for (var j = 0; j < length; j++) pids.push(options.advanced ? {
6265
- ppid: curpid,
6266
- pid: tree[curpid][j]
6267
- } : tree[curpid][j]);
6268
- delete tree[curpid];
6269
- }
6270
- if (!options.root) pids.shift();
6271
- callback(null, pids);
6272
- });
6273
- }
6274
- module.exports = list;
6275
- }));
6405
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/getAbortController.js
6406
+ const Signal = {
6407
+ SIGINT: "SIGINT",
6408
+ SIGKILL: "SIGKILL"
6409
+ };
6410
+ /**
6411
+ * Get an AbortController used to cancel running tasks on failure/interruption.
6412
+ * @returns AbortController
6413
+ */
6414
+ const getAbortController = (nodeProcess = process) => {
6415
+ const abortController = new AbortController();
6416
+ nodeProcess.on(Signal.SIGINT, () => {
6417
+ abortController.abort(Signal.SIGINT);
6418
+ });
6419
+ return abortController;
6420
+ };
6276
6421
  //#endregion
6277
6422
  //#region ../../node_modules/.pnpm/string-argv@0.3.2/node_modules/string-argv/index.js
6278
- var import_pidtree = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
6279
- function pify(fn, arg1, arg2) {
6280
- return new Promise(function(resolve, reject) {
6281
- fn(arg1, arg2, function(err, data) {
6282
- if (err) return reject(err);
6283
- resolve(data);
6284
- });
6285
- });
6286
- }
6287
- /* istanbul ignore if */
6288
- if (!String.prototype.startsWith) String.prototype.startsWith = function(suffix) {
6289
- return this.substring(0, suffix.length) === suffix;
6290
- };
6291
- var pidtree = require_pidtree$1();
6292
- /**
6293
- * Get the list of children pids of the given pid.
6294
- * @public
6295
- * @param {Number|String} pid A PID. If -1 will return all the pids.
6296
- * @param {Object} [options] Optional options object.
6297
- * @param {Boolean} [options.root=false] Include the provided PID in the list.
6298
- * @param {Boolean} [options.advanced=false] Returns a list of objects in the
6299
- * format {pid: X, ppid: Y}.
6300
- * @param {Function} [callback=undefined] Called when the list is ready. If not
6301
- * provided a promise is returned instead.
6302
- * @returns {Promise.<Object[]>} Only when the callback is not provided.
6303
- */
6304
- function list(pid, options, callback) {
6305
- if (typeof options === "function") {
6306
- callback = options;
6307
- options = void 0;
6308
- }
6309
- if (typeof callback === "function") {
6310
- pidtree(pid, options, callback);
6311
- return;
6312
- }
6313
- return pify(pidtree, pid, options);
6314
- }
6315
- module.exports = list;
6316
- })))(), 1);
6317
6423
  function parseArgsStringToArgv(value, env, file) {
6318
6424
  var myRegexp = /([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi;
6319
6425
  var myString = value;
@@ -6336,7 +6442,40 @@ function firstString() {
6336
6442
  }
6337
6443
  }
6338
6444
  //#endregion
6339
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/symbols.js
6445
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/killSubprocesses.js
6446
+ const execAsync = promisify(exec);
6447
+ /**
6448
+ * End process by pid, forcefully, including child processes
6449
+ *
6450
+ * @see {@link https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill}
6451
+ *
6452
+ * @param {number} pid
6453
+ */
6454
+ const killWin32Subprocesses = async (pid) => {
6455
+ await execAsync(`taskkill /pid ${pid} /T /F`);
6456
+ };
6457
+ /**
6458
+ * Kill all processes in the group by using negative pid
6459
+ *
6460
+ * @see {@link https://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html}
6461
+ *
6462
+ * @param {number} pid
6463
+ */
6464
+ const killUnixSubprocesses = async (pid) => {
6465
+ process.kill(-pid, "SIGKILL");
6466
+ };
6467
+ /**
6468
+ * @param {number} pid
6469
+ * @param {boolean} [isWin32]
6470
+ */
6471
+ const killSubProcesses = async (pid, isWin32 = process.platform === "win32") => {
6472
+ try {
6473
+ if (isWin32) await killWin32Subprocesses(pid);
6474
+ else await killUnixSubprocesses(pid);
6475
+ } catch {}
6476
+ };
6477
+ //#endregion
6478
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/symbols.js
6340
6479
  const ApplyEmptyCommitError = Symbol("ApplyEmptyCommitError");
6341
6480
  const ConfigNotFoundError = /* @__PURE__ */ new Error("Configuration could not be found");
6342
6481
  const ConfigFormatError = /* @__PURE__ */ new Error("Configuration should be an object or a function");
@@ -6353,11 +6492,10 @@ const RestoreUnstagedChangesError = Symbol("RestoreUnstagedChangesError");
6353
6492
  const TaskError = Symbol("TaskError");
6354
6493
  const FailOnChangesError = Symbol("FailOnChangesError");
6355
6494
  //#endregion
6356
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/state.js
6495
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/state.js
6357
6496
  const getInitialState = ({ failOnChanges = false, hideUnstaged = false, hidePartiallyStaged = !hideUnstaged, quiet = false, revert = true } = {}) => ({
6358
6497
  backupHash: null,
6359
6498
  errors: /* @__PURE__ */ new Set([]),
6360
- events: new EventEmitter$1(),
6361
6499
  shouldFailOnChanges: failOnChanges,
6362
6500
  hasFilesToHide: null,
6363
6501
  output: [],
@@ -6374,12 +6512,12 @@ const shouldRestoreUnstagedChanges = (ctx) => (ctx.shouldHideUnstaged || ctx.sho
6374
6512
  const applyModificationsSkipped = (ctx) => {
6375
6513
  if (!ctx.shouldRevert || !ctx.shouldBackup) return false;
6376
6514
  if (ctx.errors.has(GitError)) return GIT_ERROR;
6377
- if (ctx.errors.has(TaskError)) return TASK_ERROR$1;
6515
+ if (ctx.errors.has(TaskError)) return TASK_ERROR;
6378
6516
  };
6379
6517
  const restoreUnstagedChangesSkipped = (ctx) => {
6380
6518
  if (ctx.errors.has(GitError)) return GIT_ERROR;
6381
6519
  if (!ctx.shouldRevert) {}
6382
- if (ctx.errors.has(TaskError)) return TASK_ERROR$1;
6520
+ if (ctx.errors.has(TaskError)) return TASK_ERROR;
6383
6521
  };
6384
6522
  const restoreOriginalStateEnabled = (ctx) => !!ctx.shouldRevert && !!ctx.shouldBackup && (ctx.errors.has(FailOnChangesError) || ctx.errors.has(TaskError) || ctx.errors.has(RestoreUnstagedChangesError));
6385
6523
  const restoreOriginalStateSkipped = (ctx) => {
@@ -6392,95 +6530,46 @@ const cleanupSkipped = (ctx) => {
6392
6530
  if (ctx.errors.has(RestoreOriginalStateError)) return GIT_ERROR;
6393
6531
  };
6394
6532
  //#endregion
6395
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/getSpawnedTask.js
6396
- const TASK_ERROR = "lint-staged:taskError";
6533
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/getSpawnedTask.js
6397
6534
  const debugLog$12 = createDebug("lint-staged:getSpawnedTask");
6398
- /** @type {(error: import('nano-spawn').SubprocessError) => string} */
6399
- const getTag = (error) => {
6400
- return error.signalName ?? "FAILED";
6401
- };
6402
6535
  /**
6403
6536
  * Handle task console output.
6404
6537
  *
6405
6538
  * @param {string} command
6406
- * @param {import('nano-spawn').Result | import('nano-spawn').SubprocessError} result
6407
- * @param {Object} ctx
6408
- * @returns {Error}
6539
+ * @param {string} output
6540
+ * @param {ReturnType<typeof getInitialState>} ctx context
6541
+ * @param {keyof typeof Signal | undefined} signal
6542
+ * @param {import('tinyexec').Result} [errorResult]
6409
6543
  */
6410
- const handleOutput = (command, result, ctx, isError = false) => {
6411
- if (result.output) {
6412
- const outputTitle = isError ? red$1(`${error} ${command}:`) : `${info} ${command}:`;
6413
- const output = [...ctx.quiet ? [] : ["", outputTitle], result.output];
6414
- ctx.output.push(output.join("\n"));
6544
+ const handleTaskOutput = (command, output, ctx, signal, errorResult) => {
6545
+ if (output) {
6546
+ const outputTitle = errorResult ? red$1(`${error} ${command}:`) : `${info} ${command}:`;
6547
+ ctx.output.push([...ctx.quiet ? [] : ["", outputTitle], output].join("\n"));
6415
6548
  return;
6416
6549
  }
6417
6550
  if (ctx.quiet) return;
6418
- if (result instanceof SubprocessError) ctx.output.push(red$1(`\n${error} ${command} failed to spawn:`), result.message, result.cause);
6419
- else if (isError) {
6420
- const message = red$1(`\n${error} ${command} failed without output (${getTag(result)}).`);
6421
- ctx.output.push(message);
6422
- }
6423
- };
6424
- /**
6425
- * Kill subprocess along with all its child processes.
6426
- * @param {import('nano-spawn').Subprocess} subprocess
6427
- */
6428
- const killSubprocess = async (subprocess) => {
6429
- let childProcess;
6430
- try {
6431
- childProcess = await subprocess.nodeChildProcess;
6432
- } catch {}
6433
- if (childProcess?.pid !== void 0) try {
6434
- for (const childPid of await (0, import_pidtree.default)(childProcess.pid)) try {
6435
- process.kill(childPid, "SIGKILL");
6436
- } catch (error) {
6437
- debugLog$12(`Failed to kill process with pid "%d": %o`, childPid, error);
6438
- }
6439
- } catch (error) {
6440
- debugLog$12(`Failed to list child processes of pid "%d": %o`, childProcess.pid, error);
6441
- }
6442
- childProcess?.kill("SIGKILL");
6443
- };
6444
- /**
6445
- * Interrupts the execution of the subprocess that we spawned if
6446
- * another task adds an error to the context.
6447
- *
6448
- * @param {Object} ctx
6449
- * @param {import('nano-spawn').Subprocess} subprocess
6450
- * @returns {() => Promise<void>} Function that clears the interval that
6451
- * checks the context.
6452
- */
6453
- const interruptExecutionOnError = (ctx, subprocess) => {
6454
- let killPromise;
6455
- const errorListener = async () => {
6456
- killPromise = killSubprocess(subprocess);
6457
- await killPromise;
6458
- };
6459
- ctx.events.on(TASK_ERROR, errorListener, { once: true });
6460
- return async () => {
6461
- ctx.events.off(TASK_ERROR, errorListener);
6462
- if (killPromise) await killPromise;
6463
- };
6551
+ if (signal === "SIGINT") ctx.output.push(red$1(`\n${error} Task interrupted: ${command}`));
6552
+ else if (signal === "SIGKILL") ctx.output.push(red$1(`\n${error} Task killed: ${command}`));
6553
+ else if (errorResult) ctx.output.push(red$1(`\n${error} Task failed to spawn: ${command}`), signal);
6464
6554
  };
6465
6555
  /**
6466
6556
  * Create a error output depending on process result.
6467
6557
  *
6468
6558
  * @param {string} command
6469
- * @param {import('nano-spawn').SubprocessError} error
6470
- * @param {Object} ctx
6559
+ * @param {import('tinyexec').Result} result
6560
+ * @param {ReturnType<typeof getInitialState>} ctx context
6561
+ * @param {keyof typeof Signal | undefined} signal
6471
6562
  * @returns {Error}
6472
6563
  */
6473
- const makeErr = (command, error, ctx) => {
6564
+ const createTaskError = (command, result, ctx, signal = "FAILED") => {
6474
6565
  ctx.errors.add(TaskError);
6475
- ctx.events.emit(TASK_ERROR, TaskError);
6476
- handleOutput(command, error, ctx, true);
6477
- const tag = getTag(error);
6478
- return /* @__PURE__ */ new Error(`${red$1(command)} ${blackBright$1(`[${tag}]`)}`);
6566
+ return new Error(`${red$1(command)} ${blackBright$1(`[${signal}]`)}`, { cause: result });
6479
6567
  };
6480
6568
  /**
6481
6569
  * Returns the task function for the linter.
6482
6570
  *
6483
6571
  * @param {Object} options
6572
+ * @param {AbortController} options.abortController
6484
6573
  * @param {boolean} [options.color]
6485
6574
  * @param {string} options.command — Linter task
6486
6575
  * @param {string} [options.continueOnError]
@@ -6491,33 +6580,56 @@ const makeErr = (command, error, ctx) => {
6491
6580
  * @param {Boolean} [options.verbose] — Always show task verbose
6492
6581
  * @returns {() => Promise<Array<string>>}
6493
6582
  */
6494
- const getSpawnedTask = ({ color, command, continueOnError = false, cwd = process.cwd(), files, topLevelDir, isFn, verbose = false }) => {
6583
+ const getSpawnedTask = ({ abortController, color, command, continueOnError = false, cwd = process.cwd(), files, topLevelDir, isFn, verbose = false }) => {
6495
6584
  const [cmd, ...args] = parseArgsStringToArgv(command);
6496
6585
  debugLog$12("cmd:", cmd);
6497
6586
  debugLog$12("args:", args);
6498
- const spawnOptions = {
6587
+ /** @type {import('tinyexec').Options}*/
6588
+ const tinyExecOptions = { nodeOptions: {
6499
6589
  cwd: /^git(\.exe)?/i.test(cmd) ? topLevelDir : cwd,
6500
- preferLocal: true,
6501
- stdin: "ignore",
6502
- env: color ? { FORCE_COLOR: "true" } : { NO_COLOR: "true" }
6503
- };
6504
- debugLog$12("Spawn options:", spawnOptions);
6590
+ env: color ? { FORCE_COLOR: "true" } : { NO_COLOR: "true" },
6591
+ stdio: ["ignore"]
6592
+ } };
6593
+ debugLog$12("Tinyexec options:", tinyExecOptions);
6594
+ /** @param {ReturnType<typeof getInitialState>} ctx context */
6505
6595
  return async (ctx = getInitialState()) => {
6506
- let quitInterruptCheck;
6596
+ const result = q(cmd, isFn ? args : args.concat(files), tinyExecOptions);
6597
+ const taskFailed = () => result.exitCode > 0 || result.process?.signalCode;
6598
+ /** @type {keyof typeof Signal | undefined} */
6599
+ let signal;
6600
+ abortController.signal.addEventListener("abort", async () => {
6601
+ if (taskFailed() || !result.process) return;
6602
+ signal = abortController.signal.reason;
6603
+ const pid = result.process.pid;
6604
+ result.process.kill(abortController.signal.reason);
6605
+ await killSubProcesses(pid);
6606
+ }, { once: true });
6607
+ let output = "";
6507
6608
  try {
6508
- const subprocess = spawn$2(cmd, isFn ? args : args.concat(files), spawnOptions);
6509
- if (!continueOnError) quitInterruptCheck = interruptExecutionOnError(ctx, subprocess);
6510
- const result = await subprocess;
6511
- if (verbose) handleOutput(command, result, ctx);
6609
+ for await (const line of result) output += line + "\n";
6512
6610
  } catch (error) {
6513
- throw makeErr(command, error, ctx);
6514
- } finally {
6515
- if (quitInterruptCheck) await quitInterruptCheck();
6611
+ /** Probably failed to spawn (ENOENT) */
6612
+ const errorSignal = error instanceof Error && error.code || "FAILED";
6613
+ if (continueOnError !== true)
6614
+ /** Other tasks should be killed */
6615
+ abortController.abort(Signal.SIGKILL);
6616
+ handleTaskOutput(command, output, ctx, errorSignal, result);
6617
+ throw createTaskError(command, result, ctx, errorSignal);
6618
+ }
6619
+ output = output.trimEnd();
6620
+ if (taskFailed()) {
6621
+ if (continueOnError !== true)
6622
+ /** Other tasks should be killed */
6623
+ abortController.abort(Signal.SIGKILL);
6624
+ if (result.process?.pid) await killSubProcesses(result.process.pid);
6625
+ handleTaskOutput(command, output, ctx, signal, result);
6626
+ throw createTaskError(command, result, ctx, result.process?.signalCode ?? signal);
6516
6627
  }
6628
+ if (verbose) handleTaskOutput(command, output, ctx, signal);
6517
6629
  };
6518
6630
  };
6519
6631
  //#endregion
6520
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/getFunctionTask.js
6632
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/getFunctionTask.js
6521
6633
  const debugLog$11 = createDebug("lint-staged:getFunctionTasks");
6522
6634
  /**
6523
6635
  * @typedef {{ title: string; task: Function }} FunctionTask
@@ -6538,7 +6650,7 @@ const getFunctionTask = async (command, files) => {
6538
6650
  try {
6539
6651
  await command.task(files.map((file) => file.filepath));
6540
6652
  } catch (e) {
6541
- throw makeErr(command.title, e, ctx);
6653
+ throw createTaskError(command.title, e, ctx);
6542
6654
  }
6543
6655
  };
6544
6656
  return [{
@@ -6547,7 +6659,7 @@ const getFunctionTask = async (command, files) => {
6547
6659
  }];
6548
6660
  };
6549
6661
  //#endregion
6550
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/getRenderer.js
6662
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/getRenderer.js
6551
6663
  const EOLRegex = new RegExp(EOL$1 + "$");
6552
6664
  const bindLogger = (consoleLogMethod) => new Writable({ write: function(chunk, encoding, next) {
6553
6665
  consoleLogMethod(chunk.toString().replace(EOLRegex, ""));
@@ -6581,12 +6693,13 @@ const getRenderer = ({ color, debug, quiet }, logger, env = process.env) => {
6581
6693
  };
6582
6694
  };
6583
6695
  //#endregion
6584
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/getSpawnedTasks.js
6696
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/getSpawnedTasks.js
6585
6697
  const debugLog$10 = createDebug("lint-staged:getSpawnedTasks");
6586
6698
  /**
6587
6699
  * Creates and returns an array of listr tasks which map to the given commands.
6588
6700
  *
6589
6701
  * @param {object} options
6702
+ * @param {AbortController} options.abortController
6590
6703
  * @param {boolean} [options.color]
6591
6704
  * @param {Array<string|Function>|string|Function} options.commands
6592
6705
  * @param {string} options.continueOnError
@@ -6595,7 +6708,7 @@ const debugLog$10 = createDebug("lint-staged:getSpawnedTasks");
6595
6708
  * @param {string} options.topLevelDir
6596
6709
  * @param {Boolean} verbose
6597
6710
  */
6598
- const getSpawnedTasks = async ({ color, commands, continueOnError, cwd, files, topLevelDir, verbose }) => {
6711
+ const getSpawnedTasks = async ({ abortController, color, commands, continueOnError, cwd, files, topLevelDir, verbose }) => {
6599
6712
  debugLog$10("Creating Listr tasks for commands %o", commands);
6600
6713
  const cmdTasks = [];
6601
6714
  const commandArray = Array.isArray(commands) ? commands : [commands];
@@ -6608,6 +6721,7 @@ const getSpawnedTasks = async ({ color, commands, continueOnError, cwd, files, t
6608
6721
  for (const command of resolvedArray) {
6609
6722
  if (isFn && typeof command !== "string") throw new Error(configurationError("[Function]", "Function task should return a string or an array of strings", resolved));
6610
6723
  const task = getSpawnedTask({
6724
+ abortController,
6611
6725
  color,
6612
6726
  command,
6613
6727
  continueOnError,
@@ -6627,7 +6741,7 @@ const getSpawnedTasks = async ({ color, commands, continueOnError, cwd, files, t
6627
6741
  return cmdTasks;
6628
6742
  };
6629
6743
  //#endregion
6630
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/getDiffCommand.js
6744
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/getDiffCommand.js
6631
6745
  /** @type {(diff?: string, diffFilter?: string) => string[]} */
6632
6746
  const getDiffCommand = (diff, diffFilter) => {
6633
6747
  /**
@@ -6644,7 +6758,7 @@ const getDiffCommand = (diff, diffFilter) => {
6644
6758
  ];
6645
6759
  };
6646
6760
  //#endregion
6647
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/parseGitZOutput.js
6761
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/parseGitZOutput.js
6648
6762
  /**
6649
6763
  * Return array of strings split from the output of `git <something> -z`.
6650
6764
  * With `-z`, git prints `fileA\u0000fileB\u0000fileC\u0000` so we need to
@@ -6652,7 +6766,7 @@ const getDiffCommand = (diff, diffFilter) => {
6652
6766
  */
6653
6767
  const parseGitZOutput = (input) => input ? input.replace(/\u0000$/, "").split("\0") : [];
6654
6768
  //#endregion
6655
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/getStagedFiles.js
6769
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/getStagedFiles.js
6656
6770
  /**
6657
6771
  * @typedef {'A'|'C'|'D'|'M'|'R'|'T'|'U'|'X'} FileSatus
6658
6772
  * @typedef { { filepath: string; status: FileSatus }} StagedFile
@@ -6723,7 +6837,7 @@ const getStagedFiles = async ({ cwd = process.cwd(), diff, diffFilter } = {}) =>
6723
6837
  }
6724
6838
  };
6725
6839
  //#endregion
6726
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/file.js
6840
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/file.js
6727
6841
  const debugLog$9 = createDebug("lint-staged:file");
6728
6842
  /**
6729
6843
  * Read contents of a file to buffer
@@ -6766,7 +6880,7 @@ const writeFile = async (filename, buffer) => {
6766
6880
  await fsPromises.writeFile(filename, buffer);
6767
6881
  };
6768
6882
  //#endregion
6769
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/gitWorkflow.js
6883
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/gitWorkflow.js
6770
6884
  const debugLog$8 = createDebug("lint-staged:GitWorkflow");
6771
6885
  const MERGE_HEAD = "MERGE_HEAD";
6772
6886
  const MERGE_MODE = "MERGE_MODE";
@@ -7145,7 +7259,7 @@ var GitWorkflow = class {
7145
7259
  }
7146
7260
  };
7147
7261
  //#endregion
7148
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/groupFilesByConfig.js
7262
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/groupFilesByConfig.js
7149
7263
  const debugLog$7 = createDebug("lint-staged:groupFilesByConfig");
7150
7264
  /**
7151
7265
  * @typedef {import('./getStagedFiles.js').StagedFile} StagedFile
@@ -7195,7 +7309,7 @@ const groupFilesByConfig = async ({ configs, files, singleConfigMode }) => {
7195
7309
  return filesByConfig;
7196
7310
  };
7197
7311
  //#endregion
7198
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/resolveGitRepo.js
7312
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/resolveGitRepo.js
7199
7313
  const debugLog$6 = createDebug("lint-staged:resolveGitRepo");
7200
7314
  /**
7201
7315
  * Relative path up to the repo top-level directory
@@ -7254,7 +7368,7 @@ const resolveGitRepo = async (cwd = process.cwd()) => {
7254
7368
  }
7255
7369
  };
7256
7370
  //#endregion
7257
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/configFiles.js
7371
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/configFiles.js
7258
7372
  const CONFIG_NAME = "lint-staged";
7259
7373
  const PACKAGE_JSON_FILE = "package.json";
7260
7374
  const PACKAGE_YAML_FILES = ["package.yaml", "package.yml"];
@@ -7283,7 +7397,7 @@ const CONFIG_FILE_NAMES = [
7283
7397
  "lint-staged.config.cts"
7284
7398
  ];
7285
7399
  //#endregion
7286
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/resolveConfig.js
7400
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/resolveConfig.js
7287
7401
  /**
7288
7402
  * require() does not exist for ESM, so we must create it to use require.resolve().
7289
7403
  * @see https://nodejs.org/api/module.html#modulecreaterequirefilename
@@ -7297,7 +7411,7 @@ function resolveConfig(configPath) {
7297
7411
  }
7298
7412
  }
7299
7413
  //#endregion
7300
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/loadConfig.js
7414
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/loadConfig.js
7301
7415
  /** @typedef {import('./index').Logger} Logger */
7302
7416
  const debugLog$5 = createDebug("lint-staged:loadConfig");
7303
7417
  const readFile = async (filename) => fsPromises.readFile(path.resolve(filename), "utf-8");
@@ -7377,7 +7491,7 @@ const loadConfig = async (configPath, logger) => {
7377
7491
  }
7378
7492
  };
7379
7493
  //#endregion
7380
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/validateBraces.js
7494
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/validateBraces.js
7381
7495
  /**
7382
7496
  * A correctly-formed brace expansion must contain unquoted opening and closing braces,
7383
7497
  * and at least one unquoted comma or a valid sequence expression.
@@ -7406,18 +7520,21 @@ const loadConfig = async (configPath, logger) => {
7406
7520
  * - *.${js} // dollar-sign inhibits expansion, so treated literally
7407
7521
  * - *.{js\,ts} // the comma is escaped, so treated literally
7408
7522
  */
7409
- const INCORRECT_BRACES_REGEXP = /(?<![\\$])({)(?:(?!(?<!\\),|\.\.|\{|\}).)*?(?<!\\)(})/g;
7523
+ const getIncorrectBracesRegexp = () => /(?<![\\$])({)(?:(?!(?<!\\),|\.\.|\{|\}).)*?(?<!\\)(})/g;
7410
7524
  /**
7411
7525
  * @param {string} pattern
7412
7526
  * @returns {string}
7413
7527
  */
7414
7528
  const stripIncorrectBraces = (pattern) => {
7415
7529
  let output = `${pattern}`;
7416
- let match = null;
7417
- while (match = INCORRECT_BRACES_REGEXP.exec(pattern)) {
7530
+ const regexp = getIncorrectBracesRegexp();
7531
+ let match = regexp.exec(output);
7532
+ while (match) {
7418
7533
  const fullMatch = match[0];
7419
7534
  const withoutBraces = fullMatch.replace(/{/, "").replace(/}/, "");
7420
7535
  output = output.replace(fullMatch, withoutBraces);
7536
+ regexp.lastIndex = 0;
7537
+ match = regexp.exec(output);
7421
7538
  }
7422
7539
  return output;
7423
7540
  };
@@ -7456,7 +7573,7 @@ const validateBraces = (pattern, logger) => {
7456
7573
  return fixedPattern;
7457
7574
  };
7458
7575
  //#endregion
7459
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/validateConfig.js
7576
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/validateConfig.js
7460
7577
  /** @typedef {import('./index').Logger} Logger */
7461
7578
  const debugLog$4 = createDebug("lint-staged:validateConfig");
7462
7579
  const validateConfigLogic = (config, configPath, logger) => {
@@ -7519,7 +7636,7 @@ const validateConfig = (config, configPath, logger) => {
7519
7636
  }
7520
7637
  };
7521
7638
  //#endregion
7522
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/searchConfigs.js
7639
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/searchConfigs.js
7523
7640
  /** @typedef {import('./index').Logger} Logger */
7524
7641
  const debugLog$3 = createDebug("lint-staged:searchConfigs");
7525
7642
  const EXEC_GIT = [
@@ -7637,7 +7754,7 @@ const searchConfigs = async ({ configObject, configPath, cwd = process.cwd(), to
7637
7754
  return foundConfigs;
7638
7755
  };
7639
7756
  //#endregion
7640
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/runAll.js
7757
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/runAll.js
7641
7758
  /** @typedef {import('./index').Logger} Logger */
7642
7759
  const debugLog$2 = createDebug("lint-staged:runAll");
7643
7760
  /**
@@ -7735,16 +7852,10 @@ const runAll = async ({ allowEmpty = false, color = false, concurrent = true, co
7735
7852
  quiet
7736
7853
  }, logger)
7737
7854
  };
7738
- /**
7739
- * This is used to set max event listener count to the total number
7740
- * of generated tasks. The event listener is used to keep track of
7741
- * the interrupt signal and kill all tasks when it happens. See the
7742
- * `interruptExecutionOnError` in `getSpawnedTask`.
7743
- */
7744
- let listrTaskCount = 0;
7745
7855
  const listrTasks = [];
7746
7856
  /** @type {Set<import('./getStagedFiles.js').StagedFile>} */
7747
7857
  const matchedFiles = /* @__PURE__ */ new Set();
7858
+ const abortController = getAbortController();
7748
7859
  for (const [configPath, { config, files }] of Object.entries(filesByConfig)) {
7749
7860
  const configName = configPath ? normalizePath(path.relative(cwd, configPath)) : "Config object";
7750
7861
  const stagedFileChunks = chunkFiles({
@@ -7763,6 +7874,7 @@ const runAll = async ({ allowEmpty = false, color = false, concurrent = true, co
7763
7874
  files,
7764
7875
  relative
7765
7876
  }).map((task) => (isFunctionTask(task.commands) ? getFunctionTask(task.commands, task.fileList) : getSpawnedTasks({
7877
+ abortController,
7766
7878
  color,
7767
7879
  commands: task.commands,
7768
7880
  continueOnError,
@@ -7792,7 +7904,6 @@ const runAll = async ({ allowEmpty = false, color = false, concurrent = true, co
7792
7904
  }
7793
7905
  };
7794
7906
  })));
7795
- listrTaskCount += chunkListrTasks.length;
7796
7907
  listrTasks.push({
7797
7908
  title: `${configName}${blackBright$1(` — ${files.length} ${files.length > 1 ? "files" : "file"}`)}` + (chunkCount > 1 ? blackBright$1(` (chunk ${index + 1}/${chunkCount})...`) : ""),
7798
7909
  task: (ctx, task) => task.newListr(chunkListrTasks, {
@@ -7826,7 +7937,7 @@ const runAll = async ({ allowEmpty = false, color = false, concurrent = true, co
7826
7937
  }),
7827
7938
  topLevelDir
7828
7939
  });
7829
- const runner = new Listr([
7940
+ await new Listr([
7830
7941
  {
7831
7942
  title: ctx.shouldBackup ? "Backing up original state..." : "Preparing lint-staged...",
7832
7943
  task: (ctx, task) => git.prepare(ctx, task)
@@ -7867,15 +7978,12 @@ const runAll = async ({ allowEmpty = false, color = false, concurrent = true, co
7867
7978
  enabled: cleanupEnabled,
7868
7979
  skip: cleanupSkipped
7869
7980
  }
7870
- ], listrOptions);
7871
- debugLog$2("Set max event listeners to the number of tasks: %i", listrTaskCount);
7872
- ctx.events.setMaxListeners(listrTaskCount);
7873
- await runner.run();
7981
+ ], listrOptions).run();
7874
7982
  if (ctx.errors.size > 0) throw createError(ctx);
7875
7983
  return ctx;
7876
7984
  };
7877
7985
  //#endregion
7878
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/validateOptions.js
7986
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/validateOptions.js
7879
7987
  const debugLog$1 = createDebug("lint-staged:validateOptions");
7880
7988
  /**
7881
7989
  * Validate lint-staged options, either from the Node.js API or the command line flags.
@@ -7897,12 +8005,12 @@ const validateOptions = async (options = {}, logger) => {
7897
8005
  debugLog$1("Validated options: %o", options);
7898
8006
  };
7899
8007
  //#endregion
7900
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/version.js
8008
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/version.js
7901
8009
  const getVersion = async () => {
7902
8010
  return JSON.parse(await fsPromises.readFile(new URL("../package.json", import.meta.url))).version;
7903
8011
  };
7904
8012
  //#endregion
7905
- //#region ../../node_modules/.pnpm/lint-staged@16.2.7/node_modules/lint-staged/lib/index.js
8013
+ //#region ../../node_modules/.pnpm/lint-staged@16.3.2/node_modules/lint-staged/lib/index.js
7906
8014
  const debugLog = createDebug("lint-staged");
7907
8015
  /**
7908
8016
  * Get the maximum length of a command-line argument string based on current platform