vite-plus 1.0.0 → 1.1.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/LICENSE +30 -5
- package/README.md +7 -7
- package/binding/index.cjs +54 -55
- package/binding/index.d.cts +50 -12
- package/dist/{agent-CKMI1a8W.js → agent-eISuMXJb.js} +2 -2
- package/dist/bin.js +9 -6
- package/dist/config/bin.js +3 -3
- package/dist/{constants-BqJiMVVU.js → constants-CCQkpaxK.js} +2 -2
- package/dist/create/bin.js +42 -10
- package/dist/{define-config-C_KGDLUZ.cjs → define-config-CREUiMmM.cjs} +2 -2
- package/dist/{define-config-Cf_5GHmY.d.ts → define-config-CeW9DETl.d.ts} +24 -8
- package/dist/{define-config-DhEJaYRc.js → define-config-Ro6PS4dP.js} +2 -2
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.d.ts +1 -1
- package/dist/define-config.js +1 -1
- package/dist/{dist-BWiANxFS.js → dist-DUsqQuw8.js} +117 -1395
- package/dist/{editor-CHfGUhxP.js → editor-B8tkz7nL.js} +94 -52
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lint-plugins.cjs +1 -1
- package/dist/migration/bin.js +54 -50
- package/dist/{oxlint-plugin-config-lMMD5fAC.js → oxlint-plugin-config-CbG58Kzr.js} +1 -1
- package/dist/oxlint-plugin.js +2 -2
- package/dist/pack-bin.js +3 -2
- package/dist/{package-Cgdlhamw.js → package-BS84eWrW.js} +7 -2
- package/dist/package-overrides-CpoQngt3.js +411 -0
- package/dist/{prompts-jMH8S4Wp.js → prompts-ByOzbMBG.js} +537 -252
- package/dist/{resolve-vite-config-BJYYtfY3.js → resolve-vite-config-Be237LWp.js} +2 -2
- package/dist/{resolve-vite-config-BPgpYMYp.js → resolve-vite-config-CofpYgnY.js} +1 -1
- package/dist/staged/bin.js +791 -742
- package/dist/sync-versions/bin.js +4 -6
- package/dist/sync-versions/bin.mjs +247 -1419
- package/dist/toolchain.js +9 -9
- package/dist/toolchain.json +9 -9
- package/dist/{tsconfig-CmKidmRD.js → tsconfig-3ONY2k2K.js} +1 -1
- package/dist/{tsconfig-BoYTBNX_.js → tsconfig-DzZ-nrx2.js} +2 -2
- package/dist/version.js +2 -2
- package/dist/versions.js +5 -5
- package/docs/guide/ci.md +3 -4
- package/docs/guide/env.md +10 -5
- package/docs/guide/github-actions-cache.md +1 -3
- package/docs/guide/ide-integration.md +3 -1
- package/docs/guide/implode.md +2 -0
- package/docs/guide/install.md +3 -0
- package/docs/guide/local-cli.md +7 -7
- package/docs/guide/migrate-rules.md +8 -0
- package/docs/guide/migrate.md +7 -7
- package/docs/guide/test.md +1 -1
- package/docs/guide/troubleshooting.md +2 -2
- package/docs/guide/upgrade-project.md +1 -1
- package/docs/guide/vitest-v5.md +2 -2
- package/docs/guide/vpx.md +2 -2
- package/package.json +31 -28
- package/dist/package-overrides-Dpn4scvN.js +0 -17
package/dist/staged/bin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime-CMFfr-1z.js";
|
|
2
2
|
import { i as log, n as errorMsg, o as printHeader } from "../terminal-MKGAuy-p.js";
|
|
3
|
-
import { o as resolveViteConfig } from "../resolve-vite-config-
|
|
3
|
+
import { o as resolveViteConfig } from "../resolve-vite-config-Be237LWp.js";
|
|
4
4
|
import { t as unwrapCliParseOutcome } from "../cli-parse-DHE8NrBU.js";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import path, { basename, delimiter, dirname, normalize, resolve } from "node:path";
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
8
|
import { parseStagedArgs } from "../../binding/index.js";
|
|
9
|
-
import util, { formatWithOptions, inspect, promisify } from "node:util";
|
|
9
|
+
import util, { format, formatWithOptions, inspect, promisify } from "node:util";
|
|
10
10
|
import { closeSync, constants, openSync, readSync, statSync } from "node:fs";
|
|
11
11
|
import { cwd } from "node:process";
|
|
12
12
|
import l__default from "node:readline";
|
|
@@ -15,7 +15,7 @@ import fsPromises, { constants as constants$1 } from "node:fs/promises";
|
|
|
15
15
|
import { PassThrough } from "node:stream";
|
|
16
16
|
import { exec, spawn } from "node:child_process";
|
|
17
17
|
import { pipeline } from "node:stream/promises";
|
|
18
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
18
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/assertGitVersion.js
|
|
19
19
|
/** @see {@link https://github.com/git/git/blob/master/Documentation/RelNotes/2.32.0.adoc} */
|
|
20
20
|
const MIN_GIT_VERSION = "2.32.0";
|
|
21
21
|
const GIT_VERSION_REGEXP = /git version\s+(\d+\.\d+\.\d+)/i;
|
|
@@ -61,7 +61,7 @@ const assertGitVersion = (gitVersionOutput) => {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
//#endregion
|
|
64
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
64
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/colors.js
|
|
65
65
|
let COLORS_ENABLED = false;
|
|
66
66
|
/** Node.js util checks for FORCE_COLOR/NO_COLOR and whether TTY supports ANSI colors */
|
|
67
67
|
const supportsColors = (stream = process.stdout) => util.styleText("red", "test", { stream }) !== "test";
|
|
@@ -81,8 +81,8 @@ const blue = styleText$1("blue");
|
|
|
81
81
|
const dim = styleText$1("dim");
|
|
82
82
|
const bold = styleText$1("bold");
|
|
83
83
|
//#endregion
|
|
84
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
85
|
-
const format = (...args) => formatWithOptions({ colors: COLORS_ENABLED }, ...args);
|
|
84
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/debug.js
|
|
85
|
+
const format$1 = (...args) => formatWithOptions({ colors: COLORS_ENABLED }, ...args);
|
|
86
86
|
let activeLogger;
|
|
87
87
|
const enableDebug = (logger = console) => {
|
|
88
88
|
activeLogger = logger;
|
|
@@ -95,7 +95,7 @@ const createDebug = (name) => {
|
|
|
95
95
|
const now = process.hrtime.bigint();
|
|
96
96
|
const ms = (now - previous) / 1000000n;
|
|
97
97
|
previous = now;
|
|
98
|
-
activeLogger.debug(dim(name + ": ") + format(...args) + dim(` +${ms}ms`));
|
|
98
|
+
activeLogger.debug(dim(name + ": ") + format$1(...args) + dim(` +${ms}ms`));
|
|
99
99
|
};
|
|
100
100
|
};
|
|
101
101
|
//#endregion
|
|
@@ -440,7 +440,7 @@ const x = (command, args, userOptions) => {
|
|
|
440
440
|
};
|
|
441
441
|
const exec$1 = x;
|
|
442
442
|
//#endregion
|
|
443
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
443
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/execGit.js
|
|
444
444
|
const debugLog$17 = createDebug("lint-staged:execGit");
|
|
445
445
|
/**
|
|
446
446
|
* Explicitly never recurse commands into submodules, overriding local/global configuration.
|
|
@@ -448,7 +448,11 @@ const debugLog$17 = createDebug("lint-staged:execGit");
|
|
|
448
448
|
*/
|
|
449
449
|
const NO_SUBMODULE_RECURSE = ["-c", "submodule.recurse=false"];
|
|
450
450
|
[...NO_SUBMODULE_RECURSE];
|
|
451
|
-
/**
|
|
451
|
+
/**
|
|
452
|
+
* @param {string[]} cmd
|
|
453
|
+
* @param {{ cwd?: string, env?: NodeJS.ProcessEnv, trim?: boolean }} [options]
|
|
454
|
+
* @returns {Promise<string>}
|
|
455
|
+
*/
|
|
452
456
|
const execGit = async (cmd, options) => {
|
|
453
457
|
debugLog$17("Running git command:", cmd);
|
|
454
458
|
const result = await exec$1("git", [...NO_SUBMODULE_RECURSE, ...cmd], { nodeOptions: {
|
|
@@ -456,10 +460,11 @@ const execGit = async (cmd, options) => {
|
|
|
456
460
|
cwd: options?.cwd
|
|
457
461
|
} });
|
|
458
462
|
if (result.exitCode > 0) throw new Error(result.stderr.trimEnd(), { cause: result });
|
|
463
|
+
if (options?.trim === false) return result.stdout;
|
|
459
464
|
return result.stdout.trimEnd();
|
|
460
465
|
};
|
|
461
466
|
//#endregion
|
|
462
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
467
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/figures.js
|
|
463
468
|
const wip = () => blue("⋯");
|
|
464
469
|
const done = () => green("✔");
|
|
465
470
|
const info = () => blue("→");
|
|
@@ -470,7 +475,7 @@ const parallelGroupStart = () => dim("┌");
|
|
|
470
475
|
const parallelGroupMiddle = () => dim("│");
|
|
471
476
|
const parallelGroupStop = () => dim("└");
|
|
472
477
|
//#endregion
|
|
473
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
478
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/messages.js
|
|
474
479
|
const configurationError = (opt, helpMsg, value) => `${red(`${error()} Validation Error:`)}
|
|
475
480
|
|
|
476
481
|
Invalid value for '${bold(opt)}': ${bold(inspect(value))}
|
|
@@ -525,246 +530,7 @@ const minGitVersionRequired = (expected) => red(`${error()} lint-staged requires
|
|
|
525
530
|
|
|
526
531
|
Please update Git: https://git-scm.com/downloads`);
|
|
527
532
|
//#endregion
|
|
528
|
-
//#region ../../node_modules/.pnpm/
|
|
529
|
-
function parseArgsStringToArgv(value, env, file) {
|
|
530
|
-
var myRegexp = /([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi;
|
|
531
|
-
var myString = value;
|
|
532
|
-
var myArray = [];
|
|
533
|
-
if (env) myArray.push(env);
|
|
534
|
-
if (file) myArray.push(file);
|
|
535
|
-
var match;
|
|
536
|
-
do {
|
|
537
|
-
match = myRegexp.exec(myString);
|
|
538
|
-
if (match !== null) myArray.push(firstString(match[1], match[6], match[0]));
|
|
539
|
-
} while (match !== null);
|
|
540
|
-
return myArray;
|
|
541
|
-
}
|
|
542
|
-
function firstString() {
|
|
543
|
-
var args = [];
|
|
544
|
-
for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
|
|
545
|
-
for (var i = 0; i < args.length; i++) {
|
|
546
|
-
var arg = args[i];
|
|
547
|
-
if (typeof arg === "string") return arg;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
//#endregion
|
|
551
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/getAbortController.js
|
|
552
|
-
const Signal = {
|
|
553
|
-
SIGINT: "SIGINT",
|
|
554
|
-
SIGKILL: "SIGKILL"
|
|
555
|
-
};
|
|
556
|
-
/**
|
|
557
|
-
* Get an AbortController used to cancel running tasks on failure/interruption.
|
|
558
|
-
* @returns AbortController
|
|
559
|
-
*/
|
|
560
|
-
const getAbortController = (nodeProcess = process) => {
|
|
561
|
-
const abortController = new AbortController();
|
|
562
|
-
nodeProcess.on(Signal.SIGINT, () => {
|
|
563
|
-
abortController.abort(Signal.SIGINT);
|
|
564
|
-
});
|
|
565
|
-
return abortController;
|
|
566
|
-
};
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/killSubprocesses.js
|
|
569
|
-
const execAsync = promisify(exec);
|
|
570
|
-
/**
|
|
571
|
-
* End process by pid, forcefully, including child processes
|
|
572
|
-
*
|
|
573
|
-
* @see {@link https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill}
|
|
574
|
-
*
|
|
575
|
-
* @param {number} pid
|
|
576
|
-
*/
|
|
577
|
-
const killWin32Subprocesses = async (pid) => {
|
|
578
|
-
await execAsync(`taskkill /pid ${pid} /T /F`);
|
|
579
|
-
};
|
|
580
|
-
/**
|
|
581
|
-
* Kill all processes in the group by using negative pid
|
|
582
|
-
*
|
|
583
|
-
* @see {@link https://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html}
|
|
584
|
-
*
|
|
585
|
-
* @param {number} pid
|
|
586
|
-
*/
|
|
587
|
-
const killUnixSubprocesses = async (pid) => {
|
|
588
|
-
process.kill(-pid, "SIGKILL");
|
|
589
|
-
};
|
|
590
|
-
/**
|
|
591
|
-
* @param {number} pid
|
|
592
|
-
* @param {boolean} [isWin32]
|
|
593
|
-
*/
|
|
594
|
-
const killSubProcesses = async (pid, isWin32 = process.platform === "win32") => {
|
|
595
|
-
try {
|
|
596
|
-
if (isWin32) await killWin32Subprocesses(pid);
|
|
597
|
-
else await killUnixSubprocesses(pid);
|
|
598
|
-
} catch {}
|
|
599
|
-
};
|
|
600
|
-
//#endregion
|
|
601
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/symbols.js
|
|
602
|
-
const ApplyEmptyCommitError = Symbol("ApplyEmptyCommitError");
|
|
603
|
-
const ConfigNotFoundError = /* @__PURE__ */ new Error("Configuration could not be found");
|
|
604
|
-
const ConfigFormatError = /* @__PURE__ */ new Error("Configuration should be an object or a function");
|
|
605
|
-
const ConfigEmptyError = /* @__PURE__ */ new Error("Configuration should not be empty");
|
|
606
|
-
const GetStagedFilesError = Symbol("GetStagedFilesError");
|
|
607
|
-
const IntentToAddError = Symbol("IntentToAddError");
|
|
608
|
-
const GitError = Symbol("GitError");
|
|
609
|
-
const GitRepoError = Symbol("GitRepoError");
|
|
610
|
-
const HideUnstagedChangesError = Symbol("HideUnstagedChangesError");
|
|
611
|
-
const InvalidOptionsError = /* @__PURE__ */ new Error("Invalid Options");
|
|
612
|
-
const RestoreMergeStatusError = Symbol("RestoreMergeStatusError");
|
|
613
|
-
const RestoreOriginalStateError = Symbol("RestoreOriginalStateError");
|
|
614
|
-
const RestoreUnstagedChangesError = Symbol("RestoreUnstagedChangesError");
|
|
615
|
-
const TaskError = Symbol("TaskError");
|
|
616
|
-
const FailOnChangesError = Symbol("FailOnChangesError");
|
|
617
|
-
//#endregion
|
|
618
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/state.js
|
|
619
|
-
const getInitialState = ({ failOnChanges = false, hideAll = false, hideUnstaged = false, hidePartiallyStaged = !(hideAll || hideUnstaged), quiet = false, revert = true } = {}) => {
|
|
620
|
-
const initialState = {
|
|
621
|
-
backupHash: void 0,
|
|
622
|
-
errors: /* @__PURE__ */ new Set([]),
|
|
623
|
-
shouldFailOnChanges: failOnChanges,
|
|
624
|
-
hasFilesToHide: null,
|
|
625
|
-
output: [],
|
|
626
|
-
quiet,
|
|
627
|
-
runId: crypto.randomBytes(4).toString("hex"),
|
|
628
|
-
shouldBackup: null,
|
|
629
|
-
shouldHideAll: hideAll,
|
|
630
|
-
shouldHideUnstaged: hideUnstaged,
|
|
631
|
-
shouldHidePartiallyStaged: hidePartiallyStaged,
|
|
632
|
-
shouldRevert: revert,
|
|
633
|
-
unstagedDiffSha256: null,
|
|
634
|
-
unstagedPatch: null
|
|
635
|
-
};
|
|
636
|
-
if (initialState.shouldHideAll) {
|
|
637
|
-
initialState.shouldHideUnstaged = false;
|
|
638
|
-
initialState.shouldHidePartiallyStaged = false;
|
|
639
|
-
} else if (initialState.shouldHideUnstaged) initialState.shouldHidePartiallyStaged = false;
|
|
640
|
-
return initialState;
|
|
641
|
-
};
|
|
642
|
-
const shouldHidePartiallyStagedFiles = (ctx) => ctx.shouldHidePartiallyStaged && ctx.hasFilesToHide;
|
|
643
|
-
const shouldRestoreUnstagedChanges = (ctx) => (ctx.shouldHideAll || ctx.shouldHideUnstaged || ctx.shouldHidePartiallyStaged) && ctx.hasFilesToHide;
|
|
644
|
-
const shouldRestoreUntrackedFiles = (ctx) => !!ctx.shouldBackup && !!ctx.shouldHideAll;
|
|
645
|
-
const updateIndexSkipped = (ctx) => {
|
|
646
|
-
if (!ctx.shouldRevert || !ctx.shouldBackup) return false;
|
|
647
|
-
if (ctx.errors.has(GitError)) return gitError();
|
|
648
|
-
if (ctx.errors.has(TaskError)) return taskError();
|
|
649
|
-
};
|
|
650
|
-
const restoreUnstagedChangesSkipped = (ctx) => {
|
|
651
|
-
if (ctx.errors.has(GitError)) return gitError();
|
|
652
|
-
if (!ctx.shouldRevert) return false;
|
|
653
|
-
if (ctx.errors.has(TaskError)) return taskError();
|
|
654
|
-
};
|
|
655
|
-
const restoreOriginalStateEnabled = (ctx) => !!ctx.shouldRevert && !!ctx.shouldBackup && (ctx.errors.has(FailOnChangesError) || ctx.errors.has(TaskError) || ctx.errors.has(RestoreUnstagedChangesError));
|
|
656
|
-
const restoreOriginalStateSkipped = (ctx) => {
|
|
657
|
-
if (ctx.errors.has(GitError) && !ctx.errors.has(RestoreUnstagedChangesError)) return gitError();
|
|
658
|
-
};
|
|
659
|
-
const cleanupEnabled = (ctx) => ctx.shouldBackup;
|
|
660
|
-
const cleanupSkipped = (ctx) => {
|
|
661
|
-
if (ctx.errors.has(FailOnChangesError) && !ctx.shouldRevert) return true;
|
|
662
|
-
/** Failed to restore hidden unstaged changes, shouldn't drop stash, @see restoreUnstagedChangesSkipped */
|
|
663
|
-
if (ctx.errors.has(RestoreUnstagedChangesError) && !ctx.shouldRevert) return gitError();
|
|
664
|
-
if (restoreOriginalStateSkipped(ctx)) return gitError();
|
|
665
|
-
if (ctx.errors.has(RestoreOriginalStateError)) return gitError();
|
|
666
|
-
};
|
|
667
|
-
//#endregion
|
|
668
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/getSpawnedTask.js
|
|
669
|
-
const debugLog$16 = createDebug("lint-staged:getSpawnedTask");
|
|
670
|
-
/**
|
|
671
|
-
* Handle task console output.
|
|
672
|
-
*
|
|
673
|
-
* @param {string} command
|
|
674
|
-
* @param {string} output
|
|
675
|
-
* @param {ReturnType<typeof getInitialState>} ctx context
|
|
676
|
-
* @param {keyof typeof Signal | undefined} signal
|
|
677
|
-
* @param {import('tinyexec').Result} [errorResult]
|
|
678
|
-
*/
|
|
679
|
-
const handleTaskOutput = (command, output, ctx, signal, errorResult) => {
|
|
680
|
-
if (output) {
|
|
681
|
-
const outputTitle = errorResult ? red(`${error()} ${command}:`) : `${info()} ${command}:`;
|
|
682
|
-
ctx.output.push([...ctx.quiet ? [] : ["", outputTitle], output].join("\n"));
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
if (ctx.quiet) return;
|
|
686
|
-
if (signal === "SIGINT") ctx.output.push(red(`\n${error()} Task interrupted: ${command}`));
|
|
687
|
-
else if (signal === "SIGKILL") ctx.output.push(red(`\n${error()} Task killed: ${command}`));
|
|
688
|
-
else if (errorResult) ctx.output.push(red(`\n${error()} Task failed to spawn: ${command}`), signal);
|
|
689
|
-
};
|
|
690
|
-
/**
|
|
691
|
-
* Create a error output depending on process result.
|
|
692
|
-
*
|
|
693
|
-
* @param {string} command
|
|
694
|
-
* @param {import('tinyexec').Result} result
|
|
695
|
-
* @param {ReturnType<typeof getInitialState>} ctx context
|
|
696
|
-
* @param {keyof typeof Signal | undefined} signal
|
|
697
|
-
* @returns {Error}
|
|
698
|
-
*/
|
|
699
|
-
const createTaskError = (command, result, ctx, signal = "FAILED") => {
|
|
700
|
-
ctx.errors.add(TaskError);
|
|
701
|
-
return new Error(`${red(command)} ${dim(`[${signal}]`)}`, { cause: result });
|
|
702
|
-
};
|
|
703
|
-
const GIT_EXE_REGEXP = /^git(\.exe)?/i;
|
|
704
|
-
/**
|
|
705
|
-
* Returns the spawnable task.
|
|
706
|
-
*
|
|
707
|
-
* @param {Object} options
|
|
708
|
-
* @param {AbortController} options.abortController
|
|
709
|
-
* @param {string} options.command — the command to spawn
|
|
710
|
-
* @param {string} [options.continueOnError]
|
|
711
|
-
* @param {string} [options.cwd]
|
|
712
|
-
* @param {String} options.topLevelDir - Current git repo top-level path
|
|
713
|
-
* @param {Boolean} options.isFn - Whether the task is a function instead of a string
|
|
714
|
-
* @param {string[]} options.files — Filepaths to run the task against
|
|
715
|
-
* @param {Boolean} [options.verbose] — Always show task verbose
|
|
716
|
-
* @returns {() => Promise<Array<string>>}
|
|
717
|
-
*/
|
|
718
|
-
const getSpawnedTask = ({ abortController, command, continueOnError = false, cwd = process.cwd(), files, topLevelDir, isFn, verbose = false }) => {
|
|
719
|
-
const [cmd, ...args] = parseArgsStringToArgv(command);
|
|
720
|
-
debugLog$16("cmd:", cmd);
|
|
721
|
-
debugLog$16("args:", args);
|
|
722
|
-
/** @type {import('tinyexec').Options}*/
|
|
723
|
-
const tinyExecOptions = { nodeOptions: {
|
|
724
|
-
cwd: GIT_EXE_REGEXP.test(cmd) ? topLevelDir : cwd,
|
|
725
|
-
env: COLORS_ENABLED ? { FORCE_COLOR: "true" } : { NO_COLOR: "true" }
|
|
726
|
-
} };
|
|
727
|
-
debugLog$16("Tinyexec options:", tinyExecOptions);
|
|
728
|
-
/** @param {ReturnType<typeof getInitialState>} ctx context */
|
|
729
|
-
return async (ctx = getInitialState()) => {
|
|
730
|
-
const result = exec$1(cmd, isFn ? args : [...args, ...files], tinyExecOptions);
|
|
731
|
-
const taskFailed = () => result.exitCode > 0 || result.process?.signalCode;
|
|
732
|
-
/** @type {keyof typeof Signal | undefined} */
|
|
733
|
-
let signal;
|
|
734
|
-
abortController.signal.addEventListener("abort", async () => {
|
|
735
|
-
if (taskFailed() || !result.process) return;
|
|
736
|
-
signal = abortController.signal.reason;
|
|
737
|
-
const pid = result.process.pid;
|
|
738
|
-
result.process.kill(abortController.signal.reason);
|
|
739
|
-
await killSubProcesses(pid);
|
|
740
|
-
}, { once: true });
|
|
741
|
-
let output = "";
|
|
742
|
-
try {
|
|
743
|
-
for await (const line of result) output += line + "\n";
|
|
744
|
-
} catch (error) {
|
|
745
|
-
/** Probably failed to spawn (ENOENT) */
|
|
746
|
-
const errorSignal = error instanceof Error && error.code || "FAILED";
|
|
747
|
-
if (continueOnError !== true)
|
|
748
|
-
/** Other tasks should be killed */
|
|
749
|
-
abortController.abort(Signal.SIGKILL);
|
|
750
|
-
handleTaskOutput(command, output, ctx, errorSignal, result);
|
|
751
|
-
throw createTaskError(command, result, ctx, errorSignal);
|
|
752
|
-
}
|
|
753
|
-
output = output.trimEnd();
|
|
754
|
-
if (taskFailed()) {
|
|
755
|
-
if (continueOnError !== true)
|
|
756
|
-
/** Other tasks should be killed */
|
|
757
|
-
abortController.abort(Signal.SIGKILL);
|
|
758
|
-
if (result.process?.pid) await killSubProcesses(result.process.pid);
|
|
759
|
-
handleTaskOutput(command, output, ctx, signal, result);
|
|
760
|
-
throw createTaskError(command, result, ctx, result.process?.signalCode ?? signal);
|
|
761
|
-
}
|
|
762
|
-
if (verbose) handleTaskOutput(command, output, ctx, signal);
|
|
763
|
-
};
|
|
764
|
-
};
|
|
765
|
-
//#endregion
|
|
766
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/getSpawnedTasks.js
|
|
767
|
-
const debugLog$15 = createDebug("lint-staged:getSpawnedTasks");
|
|
533
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/getMaxArgLength.js
|
|
768
534
|
/**
|
|
769
535
|
* Get the maximum length of a command-line argument string based on current platform
|
|
770
536
|
*
|
|
@@ -779,90 +545,9 @@ const getMaxArgLength = (platform = process.platform) => {
|
|
|
779
545
|
default: return 131072;
|
|
780
546
|
}
|
|
781
547
|
};
|
|
782
|
-
/**
|
|
783
|
-
* Chunk `files` so that when joined with `command`, the resulting string fits into `maxArgLength`.
|
|
784
|
-
* For function commands, they are evaluated with the list of files and measured afterwards.
|
|
785
|
-
*
|
|
786
|
-
* @param {string | Function} command
|
|
787
|
-
* @param {string[]} files
|
|
788
|
-
* @param {number} [maxArgLength]
|
|
789
|
-
* @returns {Promise<Array<{ command: string, files: string[] }>>}
|
|
790
|
-
*/
|
|
791
|
-
const chunkFilesForCommand = async (command, files, maxArgLength) => {
|
|
792
|
-
const isFn = typeof command === "function";
|
|
793
|
-
const resolved = isFn ? await command([...files]) : command;
|
|
794
|
-
const resolvedCommands = Array.isArray(resolved) ? resolved : [resolved];
|
|
795
|
-
if (isFn && resolvedCommands.some((c) => typeof c !== "string")) throw new Error(configurationError("[Function]", "Function task should return a string or an array of strings", resolved));
|
|
796
|
-
if (!maxArgLength || maxArgLength === Infinity || files.length <= 1) {
|
|
797
|
-
debugLog$15("Skipping chunking because maxArgLength is %s and there are %s files", maxArgLength, files.length);
|
|
798
|
-
return resolvedCommands.map((resolvedCommand) => ({
|
|
799
|
-
command: resolvedCommand,
|
|
800
|
-
files
|
|
801
|
-
}));
|
|
802
|
-
}
|
|
803
|
-
if (resolvedCommands.every((resolvedCommand) => {
|
|
804
|
-
/**
|
|
805
|
-
* Really the command is spawned using `tinyexec` and the files passed as an array of
|
|
806
|
-
* arguments; but this approximates the length without quoting filenames.
|
|
807
|
-
*/
|
|
808
|
-
const finalCommandString = isFn ? resolvedCommand : resolvedCommand + " " + files.join(" ");
|
|
809
|
-
debugLog$15("Resolved an argument string length of %d characters from %d files", finalCommandString.length, files.length);
|
|
810
|
-
return finalCommandString.length <= maxArgLength;
|
|
811
|
-
})) return resolvedCommands.map((resolvedCommand) => ({
|
|
812
|
-
command: resolvedCommand,
|
|
813
|
-
files
|
|
814
|
-
}));
|
|
815
|
-
const middle = Math.ceil(files.length / 2);
|
|
816
|
-
const left = files.slice(0, middle);
|
|
817
|
-
const right = files.slice(middle);
|
|
818
|
-
debugLog$15("Splitting %d files into chunks of %d and %d for maxArgLength of %d", files.length, left.length, right.length, maxArgLength);
|
|
819
|
-
return (await Promise.all([chunkFilesForCommand(command, left, maxArgLength), chunkFilesForCommand(command, right, maxArgLength)])).flat();
|
|
820
|
-
};
|
|
821
|
-
/**
|
|
822
|
-
* Creates and returns an array of tasks which map to the given commands.
|
|
823
|
-
*
|
|
824
|
-
* @param {object} options
|
|
825
|
-
* @param {AbortController} options.abortController
|
|
826
|
-
* @param {Array<string | Function | Array<string | Function>> | string | Function} options.commands
|
|
827
|
-
* @param {string} options.continueOnError
|
|
828
|
-
* @param {string} options.cwd
|
|
829
|
-
* @param {import('./getStagedFiles.js').StagedFile[]} options.files
|
|
830
|
-
* @param {number} [options.maxArgLength]
|
|
831
|
-
* @param {string} options.topLevelDir
|
|
832
|
-
* @param {Boolean} verbose
|
|
833
|
-
*/
|
|
834
|
-
const getSpawnedTasks = async ({ abortController, commands, continueOnError, cwd, files, maxArgLength, topLevelDir, verbose }) => {
|
|
835
|
-
debugLog$15("Creating tasks for commands %o", commands);
|
|
836
|
-
const commandArray = Array.isArray(commands) ? commands : [commands];
|
|
837
|
-
const filepaths = files.map((f) => f.filepath);
|
|
838
|
-
if (filepaths.length === 0) {
|
|
839
|
-
debugLog$15("Skipping task generation because no files matched", { commands });
|
|
840
|
-
return [];
|
|
841
|
-
}
|
|
842
|
-
const createTasks = async (command) => {
|
|
843
|
-
const isFn = typeof command === "function";
|
|
844
|
-
return (await chunkFilesForCommand(command, filepaths, maxArgLength)).map((chunk) => ({
|
|
845
|
-
title: chunk.command,
|
|
846
|
-
task: getSpawnedTask({
|
|
847
|
-
abortController,
|
|
848
|
-
command: chunk.command,
|
|
849
|
-
continueOnError,
|
|
850
|
-
cwd,
|
|
851
|
-
files: chunk.files,
|
|
852
|
-
topLevelDir,
|
|
853
|
-
isFn,
|
|
854
|
-
verbose
|
|
855
|
-
})
|
|
856
|
-
}));
|
|
857
|
-
};
|
|
858
|
-
return (await Promise.all(commandArray.map(async (command) => {
|
|
859
|
-
if (Array.isArray(command) && command.length > 1) return [(await Promise.all(command.map(createTasks))).flat()];
|
|
860
|
-
return createTasks(command);
|
|
861
|
-
}))).flat();
|
|
862
|
-
};
|
|
863
548
|
//#endregion
|
|
864
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
865
|
-
const debugLog$
|
|
549
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/parseOptions.js
|
|
550
|
+
const debugLog$16 = createDebug("lint-staged:parseOptions");
|
|
866
551
|
/** @param {import('./index').Options} [options] */
|
|
867
552
|
const parseOptions = ({ all, allowEmpty, color, concurrent, config: configObject, configPath, continueOnError, cwd, debug, diff, diffFilter, failOnChanges, hideAll, hidePartiallyStaged, hideUnstaged, maxArgLength, quiet, relative, revert, stash, verbose } = {}) => {
|
|
868
553
|
if (all) {
|
|
@@ -912,11 +597,11 @@ const parseOptions = ({ all, allowEmpty, color, concurrent, config: configObject
|
|
|
912
597
|
stash,
|
|
913
598
|
verbose
|
|
914
599
|
};
|
|
915
|
-
debugLog$
|
|
600
|
+
debugLog$16("Parsed options: %o", options);
|
|
916
601
|
return options;
|
|
917
602
|
};
|
|
918
603
|
//#endregion
|
|
919
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
604
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/printTaskOutput.js
|
|
920
605
|
/**
|
|
921
606
|
* Handle logging of task `ctx.output` to the specified `logger`
|
|
922
607
|
* @param {Object} ctx - The context
|
|
@@ -2833,7 +2518,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2833
2518
|
module.exports = picomatch;
|
|
2834
2519
|
}));
|
|
2835
2520
|
//#endregion
|
|
2836
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
2521
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/matchFiles.js
|
|
2837
2522
|
var import_picomatch = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2838
2523
|
const pico = require_picomatch$1();
|
|
2839
2524
|
const utils = require_utils();
|
|
@@ -2864,7 +2549,7 @@ const matchFiles = (files, pattern, cwd = process.cwd()) => {
|
|
|
2864
2549
|
return files.filter((file) => isMatch(file.filepath));
|
|
2865
2550
|
};
|
|
2866
2551
|
//#endregion
|
|
2867
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
2552
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/normalizePath.js
|
|
2868
2553
|
/**
|
|
2869
2554
|
* Reimplementation of "normalize-path"
|
|
2870
2555
|
* @see https://github.com/jonschlinkert/normalize-path/blob/52c3a95ebebc2d98c1ad7606cbafa7e658656899/index.js
|
|
@@ -2902,8 +2587,8 @@ const normalizePath = (input) => {
|
|
|
2902
2587
|
return normalized;
|
|
2903
2588
|
};
|
|
2904
2589
|
//#endregion
|
|
2905
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
2906
|
-
const debugLog$
|
|
2590
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/generateTasks.js
|
|
2591
|
+
const debugLog$15 = createDebug("lint-staged:generateTasks");
|
|
2907
2592
|
/**
|
|
2908
2593
|
* Generates all task commands, and filelist
|
|
2909
2594
|
*
|
|
@@ -2914,7 +2599,7 @@ const debugLog$13 = createDebug("lint-staged:generateTasks");
|
|
|
2914
2599
|
* @param {boolean} [options.relative] - Whether filepaths to should be relative to cwd
|
|
2915
2600
|
*/
|
|
2916
2601
|
const generateTasks = ({ config, cwd = process.cwd(), files, relative = false }) => {
|
|
2917
|
-
debugLog$
|
|
2602
|
+
debugLog$15("Generating tasks");
|
|
2918
2603
|
/** @type {StagedFile[]} */
|
|
2919
2604
|
const relativeFiles = files.map((file) => ({
|
|
2920
2605
|
filepath: normalizePath(path.relative(cwd, file.filepath)),
|
|
@@ -2934,13 +2619,250 @@ const generateTasks = ({ config, cwd = process.cwd(), files, relative = false })
|
|
|
2934
2619
|
status: file.status
|
|
2935
2620
|
}))
|
|
2936
2621
|
};
|
|
2937
|
-
debugLog$
|
|
2622
|
+
debugLog$15("Generated task: \n%O", task);
|
|
2938
2623
|
return task;
|
|
2939
2624
|
});
|
|
2940
2625
|
};
|
|
2941
2626
|
//#endregion
|
|
2942
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
2943
|
-
const
|
|
2627
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/getAbortController.js
|
|
2628
|
+
const Signal = {
|
|
2629
|
+
SIGINT: "SIGINT",
|
|
2630
|
+
SIGKILL: "SIGKILL"
|
|
2631
|
+
};
|
|
2632
|
+
/**
|
|
2633
|
+
* Get an AbortController used to cancel running tasks on failure/interruption.
|
|
2634
|
+
* @returns AbortController
|
|
2635
|
+
*/
|
|
2636
|
+
const getAbortController = (nodeProcess = process) => {
|
|
2637
|
+
const abortController = new AbortController();
|
|
2638
|
+
nodeProcess.on(Signal.SIGINT, () => {
|
|
2639
|
+
abortController.abort(Signal.SIGINT);
|
|
2640
|
+
});
|
|
2641
|
+
return abortController;
|
|
2642
|
+
};
|
|
2643
|
+
//#endregion
|
|
2644
|
+
//#region ../../node_modules/.pnpm/string-argv@0.3.2/node_modules/string-argv/index.js
|
|
2645
|
+
function parseArgsStringToArgv(value, env, file) {
|
|
2646
|
+
var myRegexp = /([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi;
|
|
2647
|
+
var myString = value;
|
|
2648
|
+
var myArray = [];
|
|
2649
|
+
if (env) myArray.push(env);
|
|
2650
|
+
if (file) myArray.push(file);
|
|
2651
|
+
var match;
|
|
2652
|
+
do {
|
|
2653
|
+
match = myRegexp.exec(myString);
|
|
2654
|
+
if (match !== null) myArray.push(firstString(match[1], match[6], match[0]));
|
|
2655
|
+
} while (match !== null);
|
|
2656
|
+
return myArray;
|
|
2657
|
+
}
|
|
2658
|
+
function firstString() {
|
|
2659
|
+
var args = [];
|
|
2660
|
+
for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
|
|
2661
|
+
for (var i = 0; i < args.length; i++) {
|
|
2662
|
+
var arg = args[i];
|
|
2663
|
+
if (typeof arg === "string") return arg;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
//#endregion
|
|
2667
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/killSubprocesses.js
|
|
2668
|
+
const execAsync = promisify(exec);
|
|
2669
|
+
/**
|
|
2670
|
+
* End process by pid, forcefully, including child processes
|
|
2671
|
+
*
|
|
2672
|
+
* @see {@link https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill}
|
|
2673
|
+
*
|
|
2674
|
+
* @param {number} pid
|
|
2675
|
+
*/
|
|
2676
|
+
const killWin32Subprocesses = async (pid) => {
|
|
2677
|
+
await execAsync(`taskkill /pid ${pid} /T /F`);
|
|
2678
|
+
};
|
|
2679
|
+
/**
|
|
2680
|
+
* Kill all processes in the group by using negative pid
|
|
2681
|
+
*
|
|
2682
|
+
* @see {@link https://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html}
|
|
2683
|
+
*
|
|
2684
|
+
* @param {number} pid
|
|
2685
|
+
*/
|
|
2686
|
+
const killUnixSubprocesses = async (pid) => {
|
|
2687
|
+
process.kill(-pid, "SIGKILL");
|
|
2688
|
+
};
|
|
2689
|
+
/**
|
|
2690
|
+
* @param {number} pid
|
|
2691
|
+
* @param {boolean} [isWin32]
|
|
2692
|
+
*/
|
|
2693
|
+
const killSubProcesses = async (pid, isWin32 = process.platform === "win32") => {
|
|
2694
|
+
try {
|
|
2695
|
+
if (isWin32) await killWin32Subprocesses(pid);
|
|
2696
|
+
else await killUnixSubprocesses(pid);
|
|
2697
|
+
} catch {}
|
|
2698
|
+
};
|
|
2699
|
+
//#endregion
|
|
2700
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/symbols.js
|
|
2701
|
+
const ApplyEmptyCommitError = Symbol("ApplyEmptyCommitError");
|
|
2702
|
+
const ConfigNotFoundError = /* @__PURE__ */ new Error("Configuration could not be found");
|
|
2703
|
+
const ConfigFormatError = /* @__PURE__ */ new Error("Configuration should be an object or a function");
|
|
2704
|
+
const ConfigEmptyError = /* @__PURE__ */ new Error("Configuration should not be empty");
|
|
2705
|
+
const GetStagedFilesError = Symbol("GetStagedFilesError");
|
|
2706
|
+
const IntentToAddError = Symbol("IntentToAddError");
|
|
2707
|
+
const GitError = Symbol("GitError");
|
|
2708
|
+
const GitRepoError = Symbol("GitRepoError");
|
|
2709
|
+
const HideUnstagedChangesError = Symbol("HideUnstagedChangesError");
|
|
2710
|
+
const InvalidOptionsError = /* @__PURE__ */ new Error("Invalid Options");
|
|
2711
|
+
const RestoreMergeStatusError = Symbol("RestoreMergeStatusError");
|
|
2712
|
+
const RestoreOriginalStateError = Symbol("RestoreOriginalStateError");
|
|
2713
|
+
const RestoreUnstagedChangesError = Symbol("RestoreUnstagedChangesError");
|
|
2714
|
+
const TaskError = Symbol("TaskError");
|
|
2715
|
+
const FailOnChangesError = Symbol("FailOnChangesError");
|
|
2716
|
+
//#endregion
|
|
2717
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/state.js
|
|
2718
|
+
const getInitialState = ({ failOnChanges = false, hideAll = false, hideUnstaged = false, hidePartiallyStaged = !(hideAll || hideUnstaged), quiet = false, revert = true } = {}) => {
|
|
2719
|
+
const initialState = {
|
|
2720
|
+
backupHash: void 0,
|
|
2721
|
+
errors: /* @__PURE__ */ new Set([]),
|
|
2722
|
+
shouldFailOnChanges: failOnChanges,
|
|
2723
|
+
hasFilesToHide: null,
|
|
2724
|
+
output: [],
|
|
2725
|
+
quiet,
|
|
2726
|
+
runId: crypto.randomBytes(4).toString("hex"),
|
|
2727
|
+
shouldBackup: null,
|
|
2728
|
+
shouldHideAll: hideAll,
|
|
2729
|
+
shouldHideUnstaged: hideUnstaged,
|
|
2730
|
+
shouldHidePartiallyStaged: hidePartiallyStaged,
|
|
2731
|
+
shouldRevert: revert,
|
|
2732
|
+
unstagedDiff: null,
|
|
2733
|
+
unstagedPatch: null
|
|
2734
|
+
};
|
|
2735
|
+
if (initialState.shouldHideAll) {
|
|
2736
|
+
initialState.shouldHideUnstaged = false;
|
|
2737
|
+
initialState.shouldHidePartiallyStaged = false;
|
|
2738
|
+
} else if (initialState.shouldHideUnstaged) initialState.shouldHidePartiallyStaged = false;
|
|
2739
|
+
return initialState;
|
|
2740
|
+
};
|
|
2741
|
+
const shouldHidePartiallyStagedFiles = (ctx) => ctx.shouldHidePartiallyStaged && ctx.hasFilesToHide;
|
|
2742
|
+
const shouldRestoreUnstagedChanges = (ctx) => (ctx.shouldHideAll || ctx.shouldHideUnstaged || ctx.shouldHidePartiallyStaged) && ctx.hasFilesToHide;
|
|
2743
|
+
const shouldRestoreUntrackedFiles = (ctx) => !!ctx.shouldBackup && !!ctx.shouldHideAll;
|
|
2744
|
+
const updateIndexSkipped = (ctx) => {
|
|
2745
|
+
if (!ctx.shouldRevert || !ctx.shouldBackup) return false;
|
|
2746
|
+
if (ctx.errors.has(GitError)) return gitError();
|
|
2747
|
+
if (ctx.errors.has(TaskError)) return taskError();
|
|
2748
|
+
};
|
|
2749
|
+
const restoreUnstagedChangesSkipped = (ctx) => {
|
|
2750
|
+
if (ctx.errors.has(GitError)) return gitError();
|
|
2751
|
+
if (!ctx.shouldRevert) return false;
|
|
2752
|
+
if (ctx.errors.has(TaskError)) return taskError();
|
|
2753
|
+
};
|
|
2754
|
+
const restoreOriginalStateEnabled = (ctx) => !!ctx.shouldRevert && !!ctx.shouldBackup && (ctx.errors.has(FailOnChangesError) || ctx.errors.has(TaskError) || ctx.errors.has(RestoreUnstagedChangesError));
|
|
2755
|
+
const restoreOriginalStateSkipped = (ctx) => {
|
|
2756
|
+
if (ctx.errors.has(GitError) && !ctx.errors.has(RestoreUnstagedChangesError)) return gitError();
|
|
2757
|
+
};
|
|
2758
|
+
const cleanupEnabled = (ctx) => ctx.shouldBackup;
|
|
2759
|
+
const cleanupSkipped = (ctx) => {
|
|
2760
|
+
if (ctx.errors.has(FailOnChangesError) && !ctx.shouldRevert) return true;
|
|
2761
|
+
/** Failed to restore hidden unstaged changes, shouldn't drop stash, @see restoreUnstagedChangesSkipped */
|
|
2762
|
+
if (ctx.errors.has(RestoreUnstagedChangesError) && !ctx.shouldRevert) return gitError();
|
|
2763
|
+
if (restoreOriginalStateSkipped(ctx)) return gitError();
|
|
2764
|
+
if (ctx.errors.has(RestoreOriginalStateError)) return gitError();
|
|
2765
|
+
};
|
|
2766
|
+
//#endregion
|
|
2767
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/getSpawnedTask.js
|
|
2768
|
+
const debugLog$14 = createDebug("lint-staged:getSpawnedTask");
|
|
2769
|
+
/**
|
|
2770
|
+
* Handle task console output.
|
|
2771
|
+
*
|
|
2772
|
+
* @param {string} command
|
|
2773
|
+
* @param {string} output
|
|
2774
|
+
* @param {ReturnType<typeof getInitialState>} ctx context
|
|
2775
|
+
* @param {keyof typeof Signal | undefined} signal
|
|
2776
|
+
* @param {import('tinyexec').Result} [errorResult]
|
|
2777
|
+
*/
|
|
2778
|
+
const handleTaskOutput = (command, output, ctx, signal, errorResult) => {
|
|
2779
|
+
if (output) {
|
|
2780
|
+
const outputTitle = errorResult ? red(`${error()} ${command}:`) : `${info()} ${command}:`;
|
|
2781
|
+
ctx.output.push([...ctx.quiet ? [] : ["", outputTitle], output].join("\n"));
|
|
2782
|
+
return;
|
|
2783
|
+
}
|
|
2784
|
+
if (ctx.quiet) return;
|
|
2785
|
+
if (signal === "SIGINT") ctx.output.push(red(`\n${error()} Task interrupted: ${command}`));
|
|
2786
|
+
else if (signal === "SIGKILL") ctx.output.push(red(`\n${error()} Task killed: ${command}`));
|
|
2787
|
+
else if (errorResult) ctx.output.push(red(`\n${error()} Task failed to spawn: ${command}`), signal);
|
|
2788
|
+
};
|
|
2789
|
+
/**
|
|
2790
|
+
* Create a error output depending on process result.
|
|
2791
|
+
*
|
|
2792
|
+
* @param {string} command
|
|
2793
|
+
* @param {import('tinyexec').Result} result
|
|
2794
|
+
* @param {ReturnType<typeof getInitialState>} ctx context
|
|
2795
|
+
* @param {keyof typeof Signal | undefined} signal
|
|
2796
|
+
* @returns {Error}
|
|
2797
|
+
*/
|
|
2798
|
+
const createTaskError = (command, result, ctx, signal = "FAILED") => {
|
|
2799
|
+
ctx.errors.add(TaskError);
|
|
2800
|
+
return new Error(`${red(command)} ${dim(`[${signal}]`)}`, { cause: result });
|
|
2801
|
+
};
|
|
2802
|
+
const GIT_EXE_REGEXP = /^git(\.exe)?/i;
|
|
2803
|
+
/**
|
|
2804
|
+
* Returns the spawnable task.
|
|
2805
|
+
*
|
|
2806
|
+
* @param {Object} options
|
|
2807
|
+
* @param {AbortController} options.abortController
|
|
2808
|
+
* @param {string} options.command — the command to spawn
|
|
2809
|
+
* @param {string} [options.continueOnError]
|
|
2810
|
+
* @param {string} [options.cwd]
|
|
2811
|
+
* @param {String} options.topLevelDir - Current git repo top-level path
|
|
2812
|
+
* @param {string[]} options.files — Filepaths to run the task against
|
|
2813
|
+
* @param {Boolean} [options.verbose] — Always show task verbose
|
|
2814
|
+
* @returns {() => Promise<Array<string>>}
|
|
2815
|
+
*/
|
|
2816
|
+
const getSpawnedTask = ({ abortController, command, continueOnError = false, cwd = process.cwd(), files, topLevelDir, verbose = false }) => {
|
|
2817
|
+
const [cmd, ...args] = parseArgsStringToArgv(command);
|
|
2818
|
+
debugLog$14("cmd:", cmd);
|
|
2819
|
+
debugLog$14("args:", args);
|
|
2820
|
+
/** @type {import('tinyexec').Options}*/
|
|
2821
|
+
const tinyExecOptions = { nodeOptions: {
|
|
2822
|
+
cwd: GIT_EXE_REGEXP.test(cmd) ? topLevelDir : cwd,
|
|
2823
|
+
env: COLORS_ENABLED ? { FORCE_COLOR: "true" } : { NO_COLOR: "true" }
|
|
2824
|
+
} };
|
|
2825
|
+
debugLog$14("Tinyexec options:", tinyExecOptions);
|
|
2826
|
+
/** @param {ReturnType<typeof getInitialState>} ctx context */
|
|
2827
|
+
return async (ctx = getInitialState()) => {
|
|
2828
|
+
const result = exec$1(cmd, [...args, ...files], tinyExecOptions);
|
|
2829
|
+
const taskFailed = () => result.exitCode > 0 || result.process?.signalCode;
|
|
2830
|
+
/** @type {keyof typeof Signal | undefined} */
|
|
2831
|
+
let signal;
|
|
2832
|
+
abortController.signal.addEventListener("abort", async () => {
|
|
2833
|
+
if (taskFailed() || !result.process) return;
|
|
2834
|
+
signal = abortController.signal.reason;
|
|
2835
|
+
const pid = result.process.pid;
|
|
2836
|
+
result.process.kill(abortController.signal.reason);
|
|
2837
|
+
await killSubProcesses(pid);
|
|
2838
|
+
}, { once: true });
|
|
2839
|
+
let output = "";
|
|
2840
|
+
try {
|
|
2841
|
+
for await (const line of result) output += line + "\n";
|
|
2842
|
+
} catch (error) {
|
|
2843
|
+
/** Probably failed to spawn (ENOENT) */
|
|
2844
|
+
const errorSignal = error instanceof Error && error.code || "FAILED";
|
|
2845
|
+
if (continueOnError !== true)
|
|
2846
|
+
/** Other tasks should be killed */
|
|
2847
|
+
abortController.abort(Signal.SIGKILL);
|
|
2848
|
+
handleTaskOutput(command, output, ctx, errorSignal, result);
|
|
2849
|
+
throw createTaskError(command, result, ctx, errorSignal);
|
|
2850
|
+
}
|
|
2851
|
+
output = output.trimEnd();
|
|
2852
|
+
if (taskFailed()) {
|
|
2853
|
+
if (continueOnError !== true)
|
|
2854
|
+
/** Other tasks should be killed */
|
|
2855
|
+
abortController.abort(Signal.SIGKILL);
|
|
2856
|
+
if (result.process?.pid) await killSubProcesses(result.process.pid);
|
|
2857
|
+
handleTaskOutput(command, output, ctx, signal, result);
|
|
2858
|
+
throw createTaskError(command, result, ctx, result.process?.signalCode ?? signal);
|
|
2859
|
+
}
|
|
2860
|
+
if (verbose) handleTaskOutput(command, output, ctx, signal);
|
|
2861
|
+
};
|
|
2862
|
+
};
|
|
2863
|
+
//#endregion
|
|
2864
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/getFunctionTask.js
|
|
2865
|
+
const debugLog$13 = createDebug("lint-staged:getFunctionTasks");
|
|
2944
2866
|
/**
|
|
2945
2867
|
* @typedef {{ title: string; task: Function }} FunctionTask
|
|
2946
2868
|
* @type {(commands: FunctionTask|Array<string|Function>|string|Function) => boolean}
|
|
@@ -2955,62 +2877,327 @@ const isFunctionTask = (commands) => typeof commands === "object" && !Array.isAr
|
|
|
2955
2877
|
* @param {FunctionTask} options.command
|
|
2956
2878
|
* @param {boolean} options.continueOnError
|
|
2957
2879
|
* @param {import('./getStagedFiles.js').StagedFile[]} options.files
|
|
2880
|
+
* @param {boolean} [options.verbose]
|
|
2958
2881
|
* @throws {Error} If the function configuration is not valid
|
|
2959
2882
|
*/
|
|
2960
|
-
const getFunctionTask = async ({ abortController, command, continueOnError, files }) => {
|
|
2961
|
-
debugLog$
|
|
2883
|
+
const getFunctionTask = async ({ abortController, command, continueOnError, files, verbose }) => {
|
|
2884
|
+
debugLog$13("Creating task for function %o", command);
|
|
2962
2885
|
const task = async (ctx) => {
|
|
2886
|
+
const output = [];
|
|
2887
|
+
const addOutput = (...args) => {
|
|
2888
|
+
output.push(format(...args));
|
|
2889
|
+
};
|
|
2963
2890
|
try {
|
|
2964
|
-
|
|
2965
|
-
|
|
2891
|
+
const filepaths = files.map((file) => file.filepath);
|
|
2892
|
+
await command.task(filepaths, { log: addOutput });
|
|
2893
|
+
} catch (error) {
|
|
2966
2894
|
if (continueOnError !== true)
|
|
2967
2895
|
/** Other tasks should be killed */
|
|
2968
2896
|
abortController.abort(Signal.SIGKILL);
|
|
2969
|
-
|
|
2897
|
+
addOutput(`\n%O`, error);
|
|
2898
|
+
const taskOutput = output.join("\n").trimEnd();
|
|
2899
|
+
handleTaskOutput(command.title, taskOutput, ctx, void 0, error);
|
|
2900
|
+
throw createTaskError(command.title, error, ctx);
|
|
2970
2901
|
}
|
|
2902
|
+
if (verbose) handleTaskOutput(command.title, output.join("\n").trimEnd(), ctx);
|
|
2971
2903
|
};
|
|
2972
2904
|
return [{
|
|
2973
2905
|
title: command.title,
|
|
2974
2906
|
task
|
|
2975
2907
|
}];
|
|
2976
2908
|
};
|
|
2977
|
-
//#endregion
|
|
2978
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
2979
|
-
const GIT_Z_REGEXP = /\u0000$/;
|
|
2909
|
+
//#endregion
|
|
2910
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/parseGitZOutput.js
|
|
2911
|
+
const GIT_Z_REGEXP = /\u0000$/;
|
|
2912
|
+
/**
|
|
2913
|
+
* Return array of strings split from the output of `git <something> -z`.
|
|
2914
|
+
* With `-z`, git prints `fileA\u0000fileB\u0000fileC\u0000` so we need to
|
|
2915
|
+
* remove the last occurrence of `\u0000` before splitting
|
|
2916
|
+
*
|
|
2917
|
+
* @param {string} input
|
|
2918
|
+
* @returns {string[]} parsed input
|
|
2919
|
+
*/
|
|
2920
|
+
const parseGitZOutput = (input) => input ? input.replace(GIT_Z_REGEXP, "").split("\0") : [];
|
|
2921
|
+
//#endregion
|
|
2922
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/getIntentToAddFiles.js
|
|
2923
|
+
const debugLog$12 = createDebug("lint-staged:getIntentToAddFiles");
|
|
2924
|
+
const getIntentToAddFiles = async ({ cwd }) => {
|
|
2925
|
+
const [stagedWithIta, stagedWithoutIta] = await Promise.all([execGit([
|
|
2926
|
+
"diff",
|
|
2927
|
+
"--staged",
|
|
2928
|
+
"--ita-visible-in-index",
|
|
2929
|
+
"--name-only",
|
|
2930
|
+
"-z"
|
|
2931
|
+
], { cwd }).then(parseGitZOutput), execGit([
|
|
2932
|
+
"diff",
|
|
2933
|
+
"--staged",
|
|
2934
|
+
"--ita-invisible-in-index",
|
|
2935
|
+
"--name-only",
|
|
2936
|
+
"-z"
|
|
2937
|
+
], { cwd }).then(parseGitZOutput)]);
|
|
2938
|
+
const set = new Set(stagedWithoutIta);
|
|
2939
|
+
const intentToAdd = stagedWithIta.filter((f) => !set.has(f)).map((f) => normalizePath(path.join(cwd, f)));
|
|
2940
|
+
debugLog$12(`Detected ${intentToAdd.length} files staged with "--intent-to-add":`, intentToAdd);
|
|
2941
|
+
return intentToAdd;
|
|
2942
|
+
};
|
|
2943
|
+
//#endregion
|
|
2944
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/validateBraces.js
|
|
2945
|
+
/**
|
|
2946
|
+
* A correctly-formed brace expansion must contain unquoted opening and closing braces,
|
|
2947
|
+
* and at least one unquoted comma or a valid sequence expression.
|
|
2948
|
+
* Any incorrectly formed brace expansion is left unchanged.
|
|
2949
|
+
*
|
|
2950
|
+
* @see https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html
|
|
2951
|
+
*
|
|
2952
|
+
* Lint-staged uses `micromatch` for brace expansion, and its behavior is to treat
|
|
2953
|
+
* invalid brace expansions as literal strings, which means they (typically) do not match
|
|
2954
|
+
* anything.
|
|
2955
|
+
*
|
|
2956
|
+
* This RegExp tries to match most cases of invalid brace expansions, so that they can be
|
|
2957
|
+
* detected, warned about, and re-formatted by removing the braces and thus hopefully
|
|
2958
|
+
* matching the files as intended by the user. The only real fix is to remove the incorrect
|
|
2959
|
+
* braces from user configuration, but this is left to the user (after seeing the warning).
|
|
2960
|
+
*
|
|
2961
|
+
* @example <caption>Globs with brace expansions</caption>
|
|
2962
|
+
* - *.{js,tx} // expanded as *.js, *.ts
|
|
2963
|
+
* - *.{{j,t}s,css} // expanded as *.js, *.ts, *.css
|
|
2964
|
+
* - file_{1..10}.css // expanded as file_1.css, file_2.css, …, file_10.css
|
|
2965
|
+
*
|
|
2966
|
+
* @example <caption>Globs with incorrect brace expansions</caption>
|
|
2967
|
+
* - *.{js} // should just be *.js
|
|
2968
|
+
* - *.{js,{ts}} // should just be *.{js,ts}
|
|
2969
|
+
* - *.\{js\} // escaped braces, so they're treated literally
|
|
2970
|
+
* - *.${js} // dollar-sign inhibits expansion, so treated literally
|
|
2971
|
+
* - *.{js\,ts} // the comma is escaped, so treated literally
|
|
2972
|
+
*/
|
|
2973
|
+
const getIncorrectBracesRegexp = () => /(?<![\\$])({)(?:(?!(?<!\\),|\.\.|\{|\}).)*?(?<!\\)(})/g;
|
|
2974
|
+
const BRACE_OPEN_REGEXP = /{/;
|
|
2975
|
+
const BRACE_CLOSE_REGEXP = /}/;
|
|
2976
|
+
/**
|
|
2977
|
+
* @param {string} pattern
|
|
2978
|
+
* @returns {string}
|
|
2979
|
+
*/
|
|
2980
|
+
const stripIncorrectBraces = (pattern) => {
|
|
2981
|
+
let output = `${pattern}`;
|
|
2982
|
+
const regexp = getIncorrectBracesRegexp();
|
|
2983
|
+
let match = regexp.exec(output);
|
|
2984
|
+
while (match) {
|
|
2985
|
+
const fullMatch = match[0];
|
|
2986
|
+
const withoutBraces = fullMatch.replace(BRACE_OPEN_REGEXP, "").replace(BRACE_CLOSE_REGEXP, "");
|
|
2987
|
+
output = output.replace(fullMatch, withoutBraces);
|
|
2988
|
+
regexp.lastIndex = 0;
|
|
2989
|
+
match = regexp.exec(output);
|
|
2990
|
+
}
|
|
2991
|
+
return output;
|
|
2992
|
+
};
|
|
2993
|
+
/**
|
|
2994
|
+
* This RegExp matches "duplicate" opening and closing braces, without any other braces
|
|
2995
|
+
* in between, where the duplication is redundant and should be removed.
|
|
2996
|
+
*
|
|
2997
|
+
* @example *.{{js,ts}} // should just be *.{js,ts}
|
|
2998
|
+
*/
|
|
2999
|
+
const DOUBLE_BRACES_REGEXP = /{{[^}{]*}}/;
|
|
3000
|
+
/**
|
|
3001
|
+
* @param {string} pattern
|
|
3002
|
+
* @returns {string}
|
|
3003
|
+
*/
|
|
3004
|
+
const stripDoubleBraces = (pattern) => {
|
|
3005
|
+
let output = `${pattern}`;
|
|
3006
|
+
const match = DOUBLE_BRACES_REGEXP.exec(pattern)?.[0];
|
|
3007
|
+
if (match) {
|
|
3008
|
+
const withoutBraces = match.replace("{{", "{").replace("}}", "}");
|
|
3009
|
+
output = output.replace(match, withoutBraces);
|
|
3010
|
+
}
|
|
3011
|
+
return output;
|
|
3012
|
+
};
|
|
3013
|
+
/**
|
|
3014
|
+
* Validate and remove incorrect brace expansions from glob pattern.
|
|
3015
|
+
* For example `*.{js}` is incorrect because it doesn't contain a `,` or `..`,
|
|
3016
|
+
* and will be reformatted as `*.js`.
|
|
3017
|
+
*
|
|
3018
|
+
* @param {string} pattern the glob pattern
|
|
3019
|
+
* @param {*} logger
|
|
3020
|
+
* @returns {string}
|
|
3021
|
+
*/
|
|
3022
|
+
const validateBraces = (pattern, logger) => {
|
|
3023
|
+
const fixedPattern = stripDoubleBraces(stripIncorrectBraces(pattern));
|
|
3024
|
+
if (fixedPattern !== pattern) logger.warn(incorrectBraces(pattern, fixedPattern));
|
|
3025
|
+
return fixedPattern;
|
|
3026
|
+
};
|
|
3027
|
+
//#endregion
|
|
3028
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/validateConfig.js
|
|
3029
|
+
/** @typedef {import('./index').Logger} Logger */
|
|
3030
|
+
const debugLog$11 = createDebug("lint-staged:validateConfig");
|
|
3031
|
+
/**
|
|
3032
|
+
* Validate commands are sequential:
|
|
3033
|
+
* - a single string/task
|
|
3034
|
+
* - an array of strings/tasks, running sequentially, with at most one level of nested arrays
|
|
3035
|
+
* for running inner strings/tasks in parallel
|
|
3036
|
+
*/
|
|
3037
|
+
const isSequentialTasks = (commands, depth = 0, allowFunctions = true) => {
|
|
3038
|
+
if (Array.isArray(commands)) return depth < 2 && commands.every((command) => isSequentialTasks(command, depth + 1, allowFunctions));
|
|
3039
|
+
return typeof commands === "string" || allowFunctions && typeof commands === "function";
|
|
3040
|
+
};
|
|
3041
|
+
const validateConfigLogic = (config, configPath, logger) => {
|
|
3042
|
+
debugLog$11("Validating config from `%s`...", configPath);
|
|
3043
|
+
if (!config || typeof config !== "object" && typeof config !== "function") throw ConfigFormatError;
|
|
3044
|
+
/**
|
|
3045
|
+
* Function configurations receive all staged files as their argument.
|
|
3046
|
+
* They are not further validated here to make sure the function gets
|
|
3047
|
+
* evaluated only once.
|
|
3048
|
+
*
|
|
3049
|
+
* @see getSpawnedTasks
|
|
3050
|
+
*/
|
|
3051
|
+
if (typeof config === "function") return { "*": config };
|
|
3052
|
+
if (Object.entries(config).length === 0) throw ConfigEmptyError;
|
|
3053
|
+
const errors = [];
|
|
3054
|
+
/**
|
|
3055
|
+
* Create a new validated config because the keys (patterns) might change.
|
|
3056
|
+
* Since the Object.reduce method already loops through each entry in the config,
|
|
3057
|
+
* it can be used for validating the values at the same time.
|
|
3058
|
+
*/
|
|
3059
|
+
const validatedConfig = Object.entries(config).reduce((collection, [pattern, task]) => {
|
|
3060
|
+
if (Array.isArray(task)) {
|
|
3061
|
+
if (!isSequentialTasks(task)) errors.push(configurationError(pattern, "Should be an array of strings or functions, or single-level nested array or strings of functions.", task));
|
|
3062
|
+
} else if (typeof task === "object") {
|
|
3063
|
+
/** Invalid function task */
|
|
3064
|
+
if (typeof task.title !== "string" || typeof task.task !== "function") errors.push(configurationError(pattern, "Function task should contain `title` and `task` fields, where `title` should be a string and `task` should be a function.", task));
|
|
3065
|
+
} else if (typeof task !== "string" && typeof task !== "function")
|
|
3066
|
+
/** Singular invalid value */
|
|
3067
|
+
errors.push(configurationError(pattern, "Should be a string, a function, an object or an array of strings and functions.", task));
|
|
3068
|
+
/**
|
|
3069
|
+
* A typical configuration error is using invalid brace expansion, like `*.{js}`.
|
|
3070
|
+
* These are automatically fixed and warned about.
|
|
3071
|
+
*/
|
|
3072
|
+
const fixedPattern = validateBraces(pattern, logger);
|
|
3073
|
+
return Object.assign(collection, { [fixedPattern]: task });
|
|
3074
|
+
}, {});
|
|
3075
|
+
if (errors.length) {
|
|
3076
|
+
const message = errors.join("\n\n");
|
|
3077
|
+
logger.error(failedToParseConfig(configPath, message));
|
|
3078
|
+
throw new Error(message);
|
|
3079
|
+
}
|
|
3080
|
+
debugLog$11("Validated config from `%s`:\n%O", configPath, config);
|
|
3081
|
+
return validatedConfig;
|
|
3082
|
+
};
|
|
3083
|
+
/**
|
|
3084
|
+
* Runs config validation. Throws error if the config is not valid.
|
|
3085
|
+
* @param {Object} config
|
|
3086
|
+
* @param {string} configPath
|
|
3087
|
+
* @param {Logger} logger
|
|
3088
|
+
* @returns {Object} config
|
|
3089
|
+
*/
|
|
3090
|
+
const validateConfig = (config, configPath, logger) => {
|
|
3091
|
+
try {
|
|
3092
|
+
return validateConfigLogic(config, configPath, logger);
|
|
3093
|
+
} catch (error) {
|
|
3094
|
+
logger.error(failedToParseConfig(configPath, error));
|
|
3095
|
+
throw error;
|
|
3096
|
+
}
|
|
3097
|
+
};
|
|
3098
|
+
//#endregion
|
|
3099
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/getSpawnedTasks.js
|
|
3100
|
+
const debugLog$10 = createDebug("lint-staged:getSpawnedTasks");
|
|
3101
|
+
/**
|
|
3102
|
+
* @param {import('./config.js').SequentialTasks} commands
|
|
3103
|
+
* @param {string[]} files
|
|
3104
|
+
* @param {number} [maxArgLength]
|
|
3105
|
+
* @param {number} [arrayDepth] the maximum depth of commands array is 2, the inner is for concurrent tasks
|
|
3106
|
+
* @returns
|
|
3107
|
+
*/
|
|
3108
|
+
const prepare = async (commands, files, maxArgLength, arrayDepth = 0) => {
|
|
3109
|
+
const isFunction = typeof commands === "function";
|
|
3110
|
+
const resolved = isFunction ? await commands([...files]) : commands;
|
|
3111
|
+
if (!isSequentialTasks(resolved, arrayDepth, !isFunction)) throw new Error(configurationError(isFunction ? "[Function]" : "[Commands]", "Commands must be strings, with at most one nested array inside the sequential task list. Function results must preserve this nesting limit.", resolved));
|
|
3112
|
+
if (Array.isArray(commands)) return [(await Promise.all(commands.map((command) => prepare(command, files, maxArgLength, arrayDepth + 1)))).flat()];
|
|
3113
|
+
/** Function tasks are meant to generate the file list themselves */
|
|
3114
|
+
const toCommand = (command) => Array.isArray(command) ? command.map(toCommand) : {
|
|
3115
|
+
command,
|
|
3116
|
+
files: isFunction ? [] : files
|
|
3117
|
+
};
|
|
3118
|
+
const prepared = toCommand(resolved);
|
|
3119
|
+
const fits = (command) => {
|
|
3120
|
+
if (Array.isArray(command)) return command.every(fits);
|
|
3121
|
+
return command.command.length + (command.files.length ? 1 + command.files.join(" ").length : 0) <= maxArgLength;
|
|
3122
|
+
};
|
|
3123
|
+
if (!maxArgLength || maxArgLength === Infinity || files.length <= 1 || fits(prepared))
|
|
3124
|
+
/** No need for chunking */
|
|
3125
|
+
return [prepared];
|
|
3126
|
+
/** Split into two chunks, and try again recursively */
|
|
3127
|
+
const middle = Math.ceil(files.length / 2);
|
|
3128
|
+
debugLog$10("Splitting %d files for maxArgLength of %d", files.length, maxArgLength);
|
|
3129
|
+
return (await Promise.all([prepare(commands, files.slice(0, middle), maxArgLength, arrayDepth), prepare(commands, files.slice(middle), maxArgLength, arrayDepth)])).flat();
|
|
3130
|
+
};
|
|
3131
|
+
/**
|
|
3132
|
+
* Resolve and validate commands, preserving sequential and parallel groups.
|
|
3133
|
+
* Functions are reevaluated for smaller file lists when chunking is necessary.
|
|
3134
|
+
* Each resulting command contains only the filenames to append when spawning it.
|
|
3135
|
+
*
|
|
3136
|
+
* @param {import('./config.js').SequentialTasks} commands
|
|
3137
|
+
* @param {string[]} files
|
|
3138
|
+
* @param {number} [maxArgLength]
|
|
3139
|
+
* @returns {Promise<Array<{ command: string, files: string[] } | Array<{ command: string, files: string[] }>>>}
|
|
3140
|
+
*/
|
|
3141
|
+
const chunkFilesForCommand = async (commands, files, maxArgLength) => {
|
|
3142
|
+
if (files.length === 0) return [];
|
|
3143
|
+
return (await prepare(commands, files, maxArgLength)).flat();
|
|
3144
|
+
};
|
|
2980
3145
|
/**
|
|
2981
|
-
*
|
|
2982
|
-
* With `-z`, git prints `fileA\u0000fileB\u0000fileC\u0000` so we need to
|
|
2983
|
-
* remove the last occurrence of `\u0000` before splitting
|
|
3146
|
+
* Creates and returns an array of tasks which map to the given commands.
|
|
2984
3147
|
*
|
|
2985
|
-
* @param {
|
|
2986
|
-
* @
|
|
3148
|
+
* @param {object} options
|
|
3149
|
+
* @param {AbortController} options.abortController
|
|
3150
|
+
* @param {Array<string | Function | Array<string | Function>> | string | Function} options.commands
|
|
3151
|
+
* @param {string} options.continueOnError
|
|
3152
|
+
* @param {string} options.cwd
|
|
3153
|
+
* @param {import('./getStagedFiles.js').StagedFile[]} options.files
|
|
3154
|
+
* @param {number} [options.maxArgLength]
|
|
3155
|
+
* @param {string} options.topLevelDir
|
|
3156
|
+
* @param {Boolean} verbose
|
|
2987
3157
|
*/
|
|
2988
|
-
const
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
const
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
"-z"
|
|
3005
|
-
], { cwd }).then(parseGitZOutput)]);
|
|
3006
|
-
const set = new Set(stagedWithoutIta);
|
|
3007
|
-
const intentToAdd = stagedWithIta.filter((f) => !set.has(f)).map((f) => normalizePath(path.join(cwd, f)));
|
|
3008
|
-
debugLog$11(`Detected ${intentToAdd.length} files staged with "--intent-to-add":`, intentToAdd);
|
|
3009
|
-
return intentToAdd;
|
|
3158
|
+
const getSpawnedTasks = async ({ abortController, commands, continueOnError, cwd, files, maxArgLength, topLevelDir, verbose }) => {
|
|
3159
|
+
debugLog$10("Creating tasks for commands %o", commands);
|
|
3160
|
+
const prepared = await chunkFilesForCommand(commands, files.map((file) => file.filepath), maxArgLength);
|
|
3161
|
+
const createTask = (command) => ({
|
|
3162
|
+
title: command.command,
|
|
3163
|
+
task: getSpawnedTask({
|
|
3164
|
+
abortController,
|
|
3165
|
+
command: command.command,
|
|
3166
|
+
continueOnError,
|
|
3167
|
+
cwd,
|
|
3168
|
+
files: command.files,
|
|
3169
|
+
topLevelDir,
|
|
3170
|
+
verbose
|
|
3171
|
+
})
|
|
3172
|
+
});
|
|
3173
|
+
return prepared.map((command) => Array.isArray(command) ? command.map(createTask) : createTask(command));
|
|
3010
3174
|
};
|
|
3011
3175
|
//#endregion
|
|
3012
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
3013
|
-
const debugLog$
|
|
3176
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/file.js
|
|
3177
|
+
const debugLog$9 = createDebug("lint-staged:file");
|
|
3178
|
+
/**
|
|
3179
|
+
* Ensure directory exists, creating it if not.
|
|
3180
|
+
* @param {string} dirname
|
|
3181
|
+
* @returns {Promise<string>} the dirname
|
|
3182
|
+
*/
|
|
3183
|
+
const ensureDir = async (dirname) => {
|
|
3184
|
+
debugLog$9("Ensuring directory exists: %s", dirname);
|
|
3185
|
+
await fsPromises.mkdir(dirname, { recursive: true });
|
|
3186
|
+
return dirname;
|
|
3187
|
+
};
|
|
3188
|
+
/**
|
|
3189
|
+
* Try removing directory, ignoring errors
|
|
3190
|
+
* @param {string} dirname
|
|
3191
|
+
*/
|
|
3192
|
+
const removeDir = async (dirname) => {
|
|
3193
|
+
debugLog$9("Removing directory: %s", dirname);
|
|
3194
|
+
try {
|
|
3195
|
+
await fsPromises.rm(dirname, {
|
|
3196
|
+
recursive: true,
|
|
3197
|
+
force: true
|
|
3198
|
+
});
|
|
3199
|
+
} catch {}
|
|
3200
|
+
};
|
|
3014
3201
|
/**
|
|
3015
3202
|
* Read contents of a file to buffer
|
|
3016
3203
|
* @param {String} filename
|
|
@@ -3018,41 +3205,27 @@ const debugLog$10 = createDebug("lint-staged:file");
|
|
|
3018
3205
|
* @returns {Promise<Buffer>}
|
|
3019
3206
|
*/
|
|
3020
3207
|
const readFile$1 = async (filename, ignoreENOENT = true) => {
|
|
3021
|
-
debugLog$
|
|
3208
|
+
debugLog$9("Reading file `%s`", filename);
|
|
3022
3209
|
try {
|
|
3023
3210
|
return await fsPromises.readFile(filename);
|
|
3024
3211
|
} catch (error) {
|
|
3025
3212
|
if (ignoreENOENT && error.code === "ENOENT") {
|
|
3026
|
-
debugLog$
|
|
3213
|
+
debugLog$9("File `%s` doesn't exist, ignoring...", filename);
|
|
3027
3214
|
return null;
|
|
3028
3215
|
} else throw error;
|
|
3029
3216
|
}
|
|
3030
3217
|
};
|
|
3031
3218
|
/**
|
|
3032
|
-
* Remove a file
|
|
3033
|
-
* @param {String} filename
|
|
3034
|
-
* @param {Boolean} [ignoreENOENT=true] — Whether to throw if the file doesn't exist
|
|
3035
|
-
*/
|
|
3036
|
-
const unlink = async (filename, ignoreENOENT = true) => {
|
|
3037
|
-
debugLog$10("Removing file `%s`", filename);
|
|
3038
|
-
try {
|
|
3039
|
-
await fsPromises.unlink(filename);
|
|
3040
|
-
} catch (error) {
|
|
3041
|
-
if (ignoreENOENT && error.code === "ENOENT") debugLog$10("File `%s` doesn't exist, ignoring...", filename);
|
|
3042
|
-
else throw error;
|
|
3043
|
-
}
|
|
3044
|
-
};
|
|
3045
|
-
/**
|
|
3046
3219
|
* Write buffer to file
|
|
3047
3220
|
* @param {String} filename
|
|
3048
3221
|
* @param {Buffer} buffer
|
|
3049
3222
|
*/
|
|
3050
3223
|
const writeFile = async (filename, buffer) => {
|
|
3051
|
-
debugLog$
|
|
3224
|
+
debugLog$9("Writing file `%s`", filename);
|
|
3052
3225
|
await fsPromises.writeFile(filename, buffer);
|
|
3053
3226
|
};
|
|
3054
3227
|
//#endregion
|
|
3055
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
3228
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/getDiffCommand.js
|
|
3056
3229
|
/** @type {(diff?: string, diffFilter?: string) => string[]} */
|
|
3057
3230
|
const getDiffCommand = (diff, diffFilter) => {
|
|
3058
3231
|
/**
|
|
@@ -3069,7 +3242,7 @@ const getDiffCommand = (diff, diffFilter) => {
|
|
|
3069
3242
|
];
|
|
3070
3243
|
};
|
|
3071
3244
|
//#endregion
|
|
3072
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
3245
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/getStagedFiles.js
|
|
3073
3246
|
/**
|
|
3074
3247
|
* @typedef {'A'|'C'|'D'|'M'|'R'|'T'|'U'|'X'} FileSatus
|
|
3075
3248
|
* @typedef { { filepath: string; status: FileSatus }} StagedFile
|
|
@@ -3176,8 +3349,8 @@ const getStagedFiles = async ({ all, cwd, gitConfigDir, diff, diffFilter }) => {
|
|
|
3176
3349
|
}
|
|
3177
3350
|
};
|
|
3178
3351
|
//#endregion
|
|
3179
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
3180
|
-
const debugLog$
|
|
3352
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/runParallelTasks.js
|
|
3353
|
+
const debugLog$8 = createDebug("lint-staged:runParallelTasks");
|
|
3181
3354
|
/** @param {Number | boolean} options.concurrent Boolean value for whether to run concurrently */
|
|
3182
3355
|
const parseConcurrency = (concurrent) => {
|
|
3183
3356
|
if (concurrent === true || concurrent === Infinity) return Infinity;
|
|
@@ -3194,25 +3367,25 @@ const parseConcurrency = (concurrent) => {
|
|
|
3194
3367
|
*/
|
|
3195
3368
|
const runParallelTasks = async (ctx, tasks, { abortController, concurrent = true, logger }) => {
|
|
3196
3369
|
const concurrency = parseConcurrency(concurrent);
|
|
3197
|
-
debugLog$
|
|
3370
|
+
debugLog$8("Running parallel tasks with concurrency:", concurrency);
|
|
3198
3371
|
const indent = tasks.length > 1 ? " " : " ";
|
|
3199
3372
|
const allPerGlobTasks = [];
|
|
3200
3373
|
for (const perConfig of tasks) {
|
|
3201
|
-
if (perConfig.skip()) debugLog$
|
|
3374
|
+
if (perConfig.skip()) debugLog$8("Skipped configuration:", perConfig.title);
|
|
3202
3375
|
else {
|
|
3203
|
-
debugLog$
|
|
3376
|
+
debugLog$8("Running configuration:", perConfig.title);
|
|
3204
3377
|
if (tasks.length > 1) logger?.log(dim(`${indent}${perConfig.title}`));
|
|
3205
3378
|
}
|
|
3206
3379
|
for (const perGlob of perConfig.task) {
|
|
3207
3380
|
if (perConfig.skip()) continue;
|
|
3208
3381
|
if (perGlob.skip()) {
|
|
3209
|
-
debugLog$
|
|
3382
|
+
debugLog$8("Skipped glob from configuration:", perConfig.title, perGlob.title);
|
|
3210
3383
|
continue;
|
|
3211
3384
|
}
|
|
3212
|
-
debugLog$
|
|
3385
|
+
debugLog$8("Running glob:", perGlob.title);
|
|
3213
3386
|
logger?.log(dim(`${indent} ${perGlob.title}`));
|
|
3214
3387
|
for (const sequentialTask of perGlob.task) if (Array.isArray(sequentialTask)) {
|
|
3215
|
-
debugLog$
|
|
3388
|
+
debugLog$8(`Running ${sequentialTask.length} parallel tasks:`, ...sequentialTask.map((t) => t.title));
|
|
3216
3389
|
sequentialTask.forEach((parallelTask, index) => {
|
|
3217
3390
|
if (index === 0) logger?.log(`${indent} ${parallelGroupStart()} ${wip()} ${parallelTask.title}`);
|
|
3218
3391
|
else {
|
|
@@ -3221,7 +3394,7 @@ const runParallelTasks = async (ctx, tasks, { abortController, concurrent = true
|
|
|
3221
3394
|
}
|
|
3222
3395
|
});
|
|
3223
3396
|
} else {
|
|
3224
|
-
debugLog$
|
|
3397
|
+
debugLog$8("Running task:", sequentialTask.title);
|
|
3225
3398
|
logger?.log(`${indent} ${wip()} ${sequentialTask.title}`);
|
|
3226
3399
|
}
|
|
3227
3400
|
allPerGlobTasks.push(perGlob.task);
|
|
@@ -3230,17 +3403,17 @@ const runParallelTasks = async (ctx, tasks, { abortController, concurrent = true
|
|
|
3230
3403
|
logger?.log("");
|
|
3231
3404
|
const runSingle = async ({ title, task }) => {
|
|
3232
3405
|
if (abortController.signal.aborted) {
|
|
3233
|
-
debugLog$
|
|
3406
|
+
debugLog$8("Skipped task because aborted:", title);
|
|
3234
3407
|
logger?.warn(`${cancelled()} ${title}`);
|
|
3235
3408
|
return;
|
|
3236
3409
|
}
|
|
3237
3410
|
try {
|
|
3238
|
-
debugLog$
|
|
3411
|
+
debugLog$8("Running task:", title);
|
|
3239
3412
|
await task(ctx);
|
|
3240
|
-
debugLog$
|
|
3413
|
+
debugLog$8("Done running task:", title);
|
|
3241
3414
|
logger?.log(`${done()} ${title}`);
|
|
3242
3415
|
} catch {
|
|
3243
|
-
debugLog$
|
|
3416
|
+
debugLog$8("Failed to run task:", title);
|
|
3244
3417
|
logger?.error(red(`${error()} ${title}`));
|
|
3245
3418
|
}
|
|
3246
3419
|
};
|
|
@@ -3256,14 +3429,14 @@ const runParallelTasks = async (ctx, tasks, { abortController, concurrent = true
|
|
|
3256
3429
|
}
|
|
3257
3430
|
};
|
|
3258
3431
|
const length = Math.min(allPerGlobTasks.length, concurrency);
|
|
3259
|
-
debugLog$
|
|
3432
|
+
debugLog$8("Running workers with concurrency:", length);
|
|
3260
3433
|
await Promise.all(Array.from({ length }, worker));
|
|
3261
|
-
debugLog$
|
|
3434
|
+
debugLog$8("Done running workers");
|
|
3262
3435
|
logger?.log("");
|
|
3263
3436
|
};
|
|
3264
3437
|
//#endregion
|
|
3265
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
3266
|
-
const debugLog$
|
|
3438
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/gitWorkflow.js
|
|
3439
|
+
const debugLog$7 = createDebug("lint-staged:GitWorkflow");
|
|
3267
3440
|
const MERGE_HEAD = "MERGE_HEAD";
|
|
3268
3441
|
const MERGE_MODE = "MERGE_MODE";
|
|
3269
3442
|
const MERGE_MSG = "MERGE_MSG";
|
|
@@ -3281,7 +3454,7 @@ const processRenames = (files, includeRenameFrom = true) => files.reduce((flatte
|
|
|
3281
3454
|
} else flattened.push(file);
|
|
3282
3455
|
return flattened;
|
|
3283
3456
|
}, []);
|
|
3284
|
-
const PATCH_UNSTAGED = "
|
|
3457
|
+
const PATCH_UNSTAGED = "unstaged.patch";
|
|
3285
3458
|
const GIT_DIFF_ARGS = [
|
|
3286
3459
|
"--binary",
|
|
3287
3460
|
"--unified=0",
|
|
@@ -3298,7 +3471,27 @@ const GIT_APPLY_ARGS = [
|
|
|
3298
3471
|
"--recount",
|
|
3299
3472
|
"--unidiff-zero"
|
|
3300
3473
|
];
|
|
3301
|
-
const
|
|
3474
|
+
const DIFF_GIT_REGEXP = /^diff --git /m;
|
|
3475
|
+
/** Parse `git diff -z --raw --patch` output to map of filename --> diff */
|
|
3476
|
+
const parseGitDiffRawWithPatch = (diff) => {
|
|
3477
|
+
if (!diff) return /* @__PURE__ */ new Map();
|
|
3478
|
+
const [raw, patch] = diff.split("\0\0");
|
|
3479
|
+
const files = parseGitZOutput(raw).filter((_, index) => index % 2 === 1);
|
|
3480
|
+
const patches = patch.split(DIFF_GIT_REGEXP).slice(1);
|
|
3481
|
+
const filenames = files.values();
|
|
3482
|
+
const result = /* @__PURE__ */ new Map();
|
|
3483
|
+
let previousHeader;
|
|
3484
|
+
let filename;
|
|
3485
|
+
for (const filePatch of patches) {
|
|
3486
|
+
const header = filePatch.slice(0, filePatch.indexOf("\n"));
|
|
3487
|
+
if (header !== previousHeader) {
|
|
3488
|
+
filename = filenames.next().value;
|
|
3489
|
+
previousHeader = header;
|
|
3490
|
+
}
|
|
3491
|
+
result.set(filename, (result.get(filename) ?? "") + filePatch);
|
|
3492
|
+
}
|
|
3493
|
+
return result;
|
|
3494
|
+
};
|
|
3302
3495
|
const QUOTES_REGEXP = /^"(.*)"$/;
|
|
3303
3496
|
/**
|
|
3304
3497
|
* The lines are wrapped in double quotes
|
|
@@ -3310,7 +3503,7 @@ var GitWorkflow = class {
|
|
|
3310
3503
|
/**
|
|
3311
3504
|
* @param {Object} opts
|
|
3312
3505
|
*/
|
|
3313
|
-
constructor({ allowEmpty, diff, diffFilter, failOnChanges, gitConfigDir, logger,
|
|
3506
|
+
constructor({ allowEmpty, diff, diffFilter, failOnChanges, gitConfigDir, logger, maxArgLength, topLevelDir }) {
|
|
3314
3507
|
this.execGit = (args, options = {}) => execGit(args, {
|
|
3315
3508
|
...options,
|
|
3316
3509
|
cwd: topLevelDir
|
|
@@ -3321,8 +3514,6 @@ var GitWorkflow = class {
|
|
|
3321
3514
|
this.gitConfigDir = gitConfigDir;
|
|
3322
3515
|
this.failOnChanges = !!failOnChanges;
|
|
3323
3516
|
this.logger = logger;
|
|
3324
|
-
/** @type {Set<import('./getStagedFiles.js').StagedFile>} */
|
|
3325
|
-
this.matchedFiles = matchedFiles;
|
|
3326
3517
|
this.maxArgLength = maxArgLength;
|
|
3327
3518
|
this.topLevelDir = topLevelDir;
|
|
3328
3519
|
/**
|
|
@@ -3334,41 +3525,34 @@ var GitWorkflow = class {
|
|
|
3334
3525
|
this.mergeMsgFilename = path.resolve(gitConfigDir, MERGE_MSG);
|
|
3335
3526
|
}
|
|
3336
3527
|
/**
|
|
3337
|
-
* Get absolute path to file hidden inside .git
|
|
3338
|
-
* @param {string} filename
|
|
3339
|
-
*/
|
|
3340
|
-
getHiddenFilepath(filename) {
|
|
3341
|
-
return path.resolve(this.gitConfigDir, `./${filename}`);
|
|
3342
|
-
}
|
|
3343
|
-
/**
|
|
3344
3528
|
* Save meta information about ongoing git merge
|
|
3345
3529
|
*/
|
|
3346
3530
|
async backupMergeStatus() {
|
|
3347
|
-
debugLog$
|
|
3531
|
+
debugLog$7("Backing up merge state...");
|
|
3348
3532
|
await Promise.all([
|
|
3349
3533
|
readFile$1(this.mergeHeadFilename).then((buffer) => this.mergeHeadBuffer = buffer),
|
|
3350
3534
|
readFile$1(this.mergeModeFilename).then((buffer) => this.mergeModeBuffer = buffer),
|
|
3351
3535
|
readFile$1(this.mergeMsgFilename).then((buffer) => this.mergeMsgBuffer = buffer)
|
|
3352
3536
|
]);
|
|
3353
|
-
debugLog$
|
|
3537
|
+
debugLog$7("Done backing up merge state!");
|
|
3354
3538
|
}
|
|
3355
3539
|
/**
|
|
3356
3540
|
* Restore meta information about ongoing git merge
|
|
3357
3541
|
*/
|
|
3358
3542
|
async restoreMergeStatus(ctx) {
|
|
3359
|
-
debugLog$
|
|
3543
|
+
debugLog$7("Restoring merge state...");
|
|
3360
3544
|
try {
|
|
3361
3545
|
await Promise.all([
|
|
3362
3546
|
this.mergeHeadBuffer && writeFile(this.mergeHeadFilename, this.mergeHeadBuffer),
|
|
3363
3547
|
this.mergeModeBuffer && writeFile(this.mergeModeFilename, this.mergeModeBuffer),
|
|
3364
3548
|
this.mergeMsgBuffer && writeFile(this.mergeMsgFilename, this.mergeMsgBuffer)
|
|
3365
3549
|
]);
|
|
3366
|
-
debugLog$
|
|
3550
|
+
debugLog$7("Done restoring merge state!");
|
|
3367
3551
|
} catch (error) {
|
|
3368
3552
|
ctx.errors.add(GitError);
|
|
3369
3553
|
ctx.errors.add(RestoreMergeStatusError);
|
|
3370
|
-
debugLog$
|
|
3371
|
-
debugLog$
|
|
3554
|
+
debugLog$7("Failed restoring merge state with error:");
|
|
3555
|
+
debugLog$7(error);
|
|
3372
3556
|
throw error;
|
|
3373
3557
|
}
|
|
3374
3558
|
}
|
|
@@ -3378,7 +3562,7 @@ var GitWorkflow = class {
|
|
|
3378
3562
|
* both the "from" and "to" filenames, where "from" is no longer on disk.
|
|
3379
3563
|
*/
|
|
3380
3564
|
async getUnstagedFiles({ onlyPartial = false } = {}) {
|
|
3381
|
-
debugLog$
|
|
3565
|
+
debugLog$7("Getting partially staged files...");
|
|
3382
3566
|
/**
|
|
3383
3567
|
* See https://git-scm.com/docs/git-status#_short_format
|
|
3384
3568
|
* Entries returned in machine format are separated by a NUL character.
|
|
@@ -3388,14 +3572,18 @@ var GitWorkflow = class {
|
|
|
3388
3572
|
* renamed file, the file names are separated by a NUL character
|
|
3389
3573
|
* (e.g. `to`\0`from`)
|
|
3390
3574
|
*/
|
|
3391
|
-
const unstagedFiles = (await this.execGit([
|
|
3575
|
+
const unstagedFiles = (await this.execGit([
|
|
3576
|
+
"status",
|
|
3577
|
+
"-z",
|
|
3578
|
+
"--untracked-files=no"
|
|
3579
|
+
])).split(GIT_STATUS_Z_REGEXP).filter((line) => {
|
|
3392
3580
|
const [index, workingTree] = line;
|
|
3393
|
-
const updatedInIndex = index !== " "
|
|
3394
|
-
const updatedInWorkingTree = workingTree !== " "
|
|
3581
|
+
const updatedInIndex = index !== " ";
|
|
3582
|
+
const updatedInWorkingTree = workingTree !== " ";
|
|
3395
3583
|
if (onlyPartial) return updatedInIndex && updatedInWorkingTree;
|
|
3396
3584
|
return updatedInWorkingTree;
|
|
3397
3585
|
}).map((line) => line.slice(3)).filter(Boolean);
|
|
3398
|
-
debugLog$
|
|
3586
|
+
debugLog$7(`Found ${onlyPartial ? "partially staged" : "unstaged"} files:`, unstagedFiles);
|
|
3399
3587
|
return unstagedFiles.length ? unstagedFiles : null;
|
|
3400
3588
|
}
|
|
3401
3589
|
/** Print stash list with commit hash and subject */
|
|
@@ -3413,6 +3601,7 @@ var GitWorkflow = class {
|
|
|
3413
3601
|
async prepare(ctx) {
|
|
3414
3602
|
this.logger.log(dim(`${wip()} ${ctx.shouldBackup ? "Backing up original state…" : "Preparing lint-staged…"}`));
|
|
3415
3603
|
try {
|
|
3604
|
+
this.hiddenPath = path.join(this.gitConfigDir, `./lint-staged/${ctx.runId}`);
|
|
3416
3605
|
if (ctx.shouldBackup) await this.backupMergeStatus();
|
|
3417
3606
|
if (ctx.shouldHideUnstaged || ctx.shouldHideAll) {
|
|
3418
3607
|
this.unstagedFiles = await this.getUnstagedFiles({ onlyPartial: false });
|
|
@@ -3422,14 +3611,14 @@ var GitWorkflow = class {
|
|
|
3422
3611
|
ctx.hasFilesToHide = !!this.unstagedFiles;
|
|
3423
3612
|
}
|
|
3424
3613
|
if (this.unstagedFiles) {
|
|
3425
|
-
|
|
3426
|
-
ctx.unstagedPatch =
|
|
3614
|
+
await ensureDir(this.hiddenPath);
|
|
3615
|
+
ctx.unstagedPatch = path.join(this.hiddenPath, PATCH_UNSTAGED);
|
|
3427
3616
|
const files = processRenames(this.unstagedFiles);
|
|
3428
3617
|
await this.execGit([
|
|
3429
3618
|
"diff",
|
|
3430
3619
|
...GIT_DIFF_ARGS,
|
|
3431
3620
|
"--output",
|
|
3432
|
-
unstagedPatch,
|
|
3621
|
+
ctx.unstagedPatch,
|
|
3433
3622
|
"--",
|
|
3434
3623
|
...files
|
|
3435
3624
|
]);
|
|
@@ -3462,18 +3651,18 @@ var GitWorkflow = class {
|
|
|
3462
3651
|
ctx.backupHash
|
|
3463
3652
|
]);
|
|
3464
3653
|
}
|
|
3465
|
-
debugLog$
|
|
3654
|
+
debugLog$7("Created backup stash with commit hash %s", ctx.backupHash);
|
|
3466
3655
|
}
|
|
3467
3656
|
this.logger.log(`${done()} ${ctx.shouldBackup ? `Done backing up original state (${await this.execGit([
|
|
3468
3657
|
"rev-parse",
|
|
3469
3658
|
"--short",
|
|
3470
3659
|
ctx.backupHash
|
|
3471
3660
|
])})!` : "Done preparing lint-staged!"}`);
|
|
3472
|
-
} catch (error$
|
|
3661
|
+
} catch (error$1) {
|
|
3473
3662
|
ctx.errors.add(GitError);
|
|
3474
3663
|
const errorMessage = ctx.shouldBackup ? "Failed to back up original state!" : "Failed to prepare lint-staged!";
|
|
3475
3664
|
this.logger.error(`${error()} ${errorMessage}`);
|
|
3476
|
-
debugLog$
|
|
3665
|
+
debugLog$7(error$1);
|
|
3477
3666
|
}
|
|
3478
3667
|
}
|
|
3479
3668
|
async hidePartiallyStagedChanges(ctx) {
|
|
@@ -3487,7 +3676,7 @@ var GitWorkflow = class {
|
|
|
3487
3676
|
...files
|
|
3488
3677
|
]);
|
|
3489
3678
|
this.logger.log(`${done()} Done hiding unstaged changes to partially staged files!`);
|
|
3490
|
-
} catch (error$
|
|
3679
|
+
} catch (error$3) {
|
|
3491
3680
|
/**
|
|
3492
3681
|
* `git checkout --force` doesn't throw errors, so it shouldn't be possible to get here.
|
|
3493
3682
|
*/
|
|
@@ -3495,24 +3684,24 @@ var GitWorkflow = class {
|
|
|
3495
3684
|
ctx.errors.add(HideUnstagedChangesError);
|
|
3496
3685
|
const errorMessage = `${error()} Failed to hude unstaged changes to partially staged files!`;
|
|
3497
3686
|
this.logger.error(errorMessage);
|
|
3498
|
-
debugLog$
|
|
3687
|
+
debugLog$7(error$3);
|
|
3499
3688
|
}
|
|
3500
3689
|
}
|
|
3501
3690
|
async runTasks(ctx, tasks, { abortController, concurrent }) {
|
|
3502
3691
|
this.logger.log(dim(`${wip()} Running tasks for ${this.diff ? "changed" : "staged"} files…`));
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
const diff = await this.execGit([
|
|
3692
|
+
try {
|
|
3693
|
+
ctx.unstagedDiff = await this.execGit([
|
|
3506
3694
|
"diff",
|
|
3507
|
-
|
|
3508
|
-
"--
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3695
|
+
...GIT_DIFF_ARGS,
|
|
3696
|
+
"--raw",
|
|
3697
|
+
"-z",
|
|
3698
|
+
"--no-renames",
|
|
3699
|
+
"--no-textconv"
|
|
3700
|
+
], { trim: false });
|
|
3512
3701
|
} catch (error) {
|
|
3513
3702
|
ctx.errors.add(GitError);
|
|
3514
|
-
this.logger.error("Failed to
|
|
3515
|
-
debugLog$
|
|
3703
|
+
this.logger.error("Failed to get diff of unstaged changes!");
|
|
3704
|
+
debugLog$7(error);
|
|
3516
3705
|
return;
|
|
3517
3706
|
}
|
|
3518
3707
|
const failureMessage = `${error()} Failed to run tasks for ${this.diff ? "changed" : "staged"} files!`;
|
|
@@ -3526,80 +3715,81 @@ var GitWorkflow = class {
|
|
|
3526
3715
|
} catch (error) {
|
|
3527
3716
|
ctx.errors.add(TaskError);
|
|
3528
3717
|
this.logger.error(failureMessage);
|
|
3529
|
-
debugLog$
|
|
3718
|
+
debugLog$7(error);
|
|
3530
3719
|
}
|
|
3531
3720
|
}
|
|
3532
3721
|
/** Update Git index again for the originally staged files to stage task modifications. */
|
|
3533
3722
|
async updateIndex(ctx) {
|
|
3534
3723
|
this.logger.log(dim(`${wip()} Staging changes from tasks…`));
|
|
3535
3724
|
try {
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3725
|
+
const diff = await this.execGit([
|
|
3726
|
+
"diff",
|
|
3727
|
+
...GIT_DIFF_ARGS,
|
|
3728
|
+
"--raw",
|
|
3729
|
+
"-z",
|
|
3730
|
+
"--no-renames",
|
|
3731
|
+
"--no-textconv"
|
|
3732
|
+
], { trim: false });
|
|
3733
|
+
const before = parseGitDiffRawWithPatch(ctx.unstagedDiff);
|
|
3734
|
+
const after = parseGitDiffRawWithPatch(diff);
|
|
3735
|
+
/** @type {Set<string>} */
|
|
3736
|
+
const addableFiles = /* @__PURE__ */ new Set();
|
|
3737
|
+
for (const file of /* @__PURE__ */ new Set([...before.keys(), ...after.keys()])) if (before.get(file) !== after.get(file)) addableFiles.add(normalizePath(path.resolve(this.topLevelDir, file)));
|
|
3738
|
+
if (ctx.shouldFailOnChanges && addableFiles.size > 0) {
|
|
3739
|
+
ctx.errors.add(FailOnChangesError);
|
|
3740
|
+
this.logger.error(`${error()} Tasks modified files and --fail-on-changes was used!`);
|
|
3741
|
+
return;
|
|
3550
3742
|
}
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
const defaultIndexLock = normalizePath(await this.execGit([
|
|
3570
|
-
"rev-parse",
|
|
3571
|
-
"--path-format=absolute",
|
|
3572
|
-
"--git-path",
|
|
3573
|
-
"index.lock"
|
|
3574
|
-
]));
|
|
3743
|
+
if (addableFiles.size > 0) {
|
|
3744
|
+
const addCommands = await chunkFilesForCommand("git add --", [...addableFiles], this.maxArgLength);
|
|
3745
|
+
const activeIndexFile = process.env.GIT_INDEX_FILE ? normalizePath(process.env.GIT_INDEX_FILE) : process.env.GIT_INDEX_FILE;
|
|
3746
|
+
const defaultIndexLock = activeIndexFile?.endsWith(".lock") ? normalizePath(await this.execGit([
|
|
3747
|
+
"rev-parse",
|
|
3748
|
+
"--path-format=absolute",
|
|
3749
|
+
"--git-path",
|
|
3750
|
+
"index.lock"
|
|
3751
|
+
])) : void 0;
|
|
3752
|
+
/** Needs to be run serially because of locking Git operation */
|
|
3753
|
+
for (const { files } of addCommands) {
|
|
3754
|
+
debugLog$7("Updating active Git index: %s", activeIndexFile);
|
|
3755
|
+
await this.execGit([
|
|
3756
|
+
"add",
|
|
3757
|
+
"--",
|
|
3758
|
+
...files
|
|
3759
|
+
]);
|
|
3760
|
+
debugLog$7("Done updating Git index: %s", activeIndexFile);
|
|
3575
3761
|
/**
|
|
3576
3762
|
* If the active index file is a non-default lockfile, we are committing with a pathspec
|
|
3577
3763
|
* without having explicitly run `git add`. In this case we need to also update the
|
|
3578
3764
|
* default index, otherwise there will be leftover diff after committing
|
|
3579
3765
|
*/
|
|
3580
|
-
if (activeIndexFile !== defaultIndexLock) {
|
|
3581
|
-
debugLog$
|
|
3766
|
+
if (defaultIndexLock && activeIndexFile !== defaultIndexLock) {
|
|
3767
|
+
debugLog$7("Updating default Git index again: %s", defaultIndexLock);
|
|
3582
3768
|
await this.execGit([
|
|
3583
3769
|
"add",
|
|
3584
3770
|
"--",
|
|
3585
3771
|
...files
|
|
3586
3772
|
], { env: { GIT_INDEX_FILE: defaultIndexLock } });
|
|
3587
|
-
debugLog$
|
|
3773
|
+
debugLog$7("Done updating default Git index lock: %s", defaultIndexLock);
|
|
3588
3774
|
}
|
|
3589
3775
|
}
|
|
3590
3776
|
}
|
|
3591
|
-
if (!
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3777
|
+
if (!this.allowEmpty) {
|
|
3778
|
+
if (parseGitZOutput(await this.execGit([
|
|
3779
|
+
...getDiffCommand(this.diff, this.diffFilter),
|
|
3780
|
+
"--name-only",
|
|
3781
|
+
"-z"
|
|
3782
|
+
])).length === 0) {
|
|
3783
|
+
ctx.errors.add(ApplyEmptyCommitError);
|
|
3784
|
+
this.logger.error(`${error()} Prevented an empty git commit!`);
|
|
3785
|
+
return;
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
this.logger.log(`${done()} Done staging changes from tasks!`);
|
|
3789
|
+
} catch (error$4) {
|
|
3600
3790
|
ctx.errors.add(GitError);
|
|
3601
3791
|
this.logger.log(`${error()} Failed to stage changes from tasks!`);
|
|
3602
|
-
debugLog$
|
|
3792
|
+
debugLog$7(error$4);
|
|
3603
3793
|
}
|
|
3604
3794
|
}
|
|
3605
3795
|
/**
|
|
@@ -3609,17 +3799,18 @@ var GitWorkflow = class {
|
|
|
3609
3799
|
*/
|
|
3610
3800
|
async restoreUnstagedChanges(ctx) {
|
|
3611
3801
|
this.logger.log(dim(`${wip()} Restoring unstaged changes…`));
|
|
3612
|
-
const unstagedPatch = this.
|
|
3802
|
+
const unstagedPatch = path.join(this.hiddenPath, PATCH_UNSTAGED);
|
|
3613
3803
|
try {
|
|
3614
3804
|
await this.execGit([
|
|
3615
3805
|
"apply",
|
|
3616
3806
|
...GIT_APPLY_ARGS,
|
|
3617
3807
|
unstagedPatch
|
|
3618
3808
|
]);
|
|
3809
|
+
await removeDir(this.hiddenPath);
|
|
3619
3810
|
} catch (applyError) {
|
|
3620
|
-
debugLog$
|
|
3621
|
-
debugLog$
|
|
3622
|
-
debugLog$
|
|
3811
|
+
debugLog$7("Error while restoring changes:");
|
|
3812
|
+
debugLog$7(applyError);
|
|
3813
|
+
debugLog$7("Retrying with 3-way merge");
|
|
3623
3814
|
try {
|
|
3624
3815
|
await this.execGit([
|
|
3625
3816
|
"apply",
|
|
@@ -3627,11 +3818,12 @@ var GitWorkflow = class {
|
|
|
3627
3818
|
"--3way",
|
|
3628
3819
|
unstagedPatch
|
|
3629
3820
|
]);
|
|
3821
|
+
await removeDir(this.hiddenPath);
|
|
3630
3822
|
} catch (threeWayApplyError) {
|
|
3631
3823
|
ctx.errors.add(GitError);
|
|
3632
3824
|
ctx.errors.add(RestoreUnstagedChangesError);
|
|
3633
3825
|
this.logger.error(`${error()} Failed to restore unstaged changes!`);
|
|
3634
|
-
debugLog$
|
|
3826
|
+
debugLog$7(threeWayApplyError);
|
|
3635
3827
|
}
|
|
3636
3828
|
}
|
|
3637
3829
|
}
|
|
@@ -3647,7 +3839,7 @@ var GitWorkflow = class {
|
|
|
3647
3839
|
untrackedTree
|
|
3648
3840
|
]).then(parseGitZOutput);
|
|
3649
3841
|
if (untrackedFiles.length) {
|
|
3650
|
-
debugLog$
|
|
3842
|
+
debugLog$7("Found untracked files: %s", untrackedFiles);
|
|
3651
3843
|
await this.execGit([
|
|
3652
3844
|
"restore",
|
|
3653
3845
|
"--source",
|
|
@@ -3661,7 +3853,7 @@ var GitWorkflow = class {
|
|
|
3661
3853
|
ctx.errors.add(GitError);
|
|
3662
3854
|
ctx.errors.add(RestoreUnstagedChangesError);
|
|
3663
3855
|
this.logger.error(`${error()} Failed to restore untracked files!`);
|
|
3664
|
-
debugLog$
|
|
3856
|
+
debugLog$7(restoreUntrackedFilesError);
|
|
3665
3857
|
}
|
|
3666
3858
|
}
|
|
3667
3859
|
/**
|
|
@@ -3670,7 +3862,7 @@ var GitWorkflow = class {
|
|
|
3670
3862
|
async restoreOriginalState(ctx) {
|
|
3671
3863
|
this.logger.log(dim(`${wip()} Reverting to original state because of errors…`));
|
|
3672
3864
|
try {
|
|
3673
|
-
debugLog$
|
|
3865
|
+
debugLog$7("Restoring original state...");
|
|
3674
3866
|
await this.execGit([
|
|
3675
3867
|
"reset",
|
|
3676
3868
|
"--hard",
|
|
@@ -3684,13 +3876,13 @@ var GitWorkflow = class {
|
|
|
3684
3876
|
ctx.backupHash
|
|
3685
3877
|
]);
|
|
3686
3878
|
await this.restoreMergeStatus(ctx);
|
|
3687
|
-
await
|
|
3879
|
+
await removeDir(this.hiddenPath);
|
|
3688
3880
|
this.logger.log(`${done()} Done reverting to original state!`);
|
|
3689
3881
|
} catch (error$5) {
|
|
3690
3882
|
ctx.errors.add(GitError);
|
|
3691
3883
|
ctx.errors.add(RestoreOriginalStateError);
|
|
3692
3884
|
this.logger.error(`${error()} Failed to revert to original state!`);
|
|
3693
|
-
debugLog$
|
|
3885
|
+
debugLog$7(error$5);
|
|
3694
3886
|
}
|
|
3695
3887
|
}
|
|
3696
3888
|
/**
|
|
@@ -3709,66 +3901,83 @@ var GitWorkflow = class {
|
|
|
3709
3901
|
]);
|
|
3710
3902
|
this.logger.log(`${done()} Done cleaning up temporary files!`);
|
|
3711
3903
|
} else this.logger.error(`${error()} lint-staged automatic backup is missing!`);
|
|
3712
|
-
} catch (error$
|
|
3904
|
+
} catch (error$2) {
|
|
3713
3905
|
ctx.errors.add(GitError);
|
|
3714
3906
|
this.logger.error(`${error()} Failed to clean up temporary files!`);
|
|
3715
|
-
debugLog$
|
|
3907
|
+
debugLog$7(error$2);
|
|
3716
3908
|
}
|
|
3717
3909
|
}
|
|
3718
3910
|
};
|
|
3719
3911
|
//#endregion
|
|
3720
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
3721
|
-
const debugLog$
|
|
3912
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/groupFilesByConfig.js
|
|
3913
|
+
const debugLog$6 = createDebug("lint-staged:groupFilesByConfig");
|
|
3722
3914
|
/**
|
|
3723
3915
|
* @typedef {import('./getStagedFiles.js').StagedFile} StagedFile
|
|
3724
|
-
* @
|
|
3916
|
+
* @typedef {import('./config.js').Configuration} Configuration
|
|
3917
|
+
* @typedef {Record<string, { config: Configuration; files: StagedFile[] }>} FilesByConfig
|
|
3918
|
+
*
|
|
3919
|
+
* @param {object} params
|
|
3920
|
+
* @param {Record<string, Configuration>} params.configs
|
|
3921
|
+
* @param {StagedFile[]} params.files
|
|
3922
|
+
* @param {boolean} [params.singleConfigMode]
|
|
3923
|
+
* @returns {Promise<FilesByConfig>}
|
|
3725
3924
|
*/
|
|
3726
3925
|
const groupFilesByConfig = async ({ configs, files, singleConfigMode }) => {
|
|
3727
|
-
debugLog$
|
|
3728
|
-
/** @type {
|
|
3729
|
-
const filesSet = new Set(files);
|
|
3730
|
-
/** @type {{[key: string]: { config: any; files: StagedFile[] } }} */
|
|
3926
|
+
debugLog$6("Grouping %d files by %d configurations", files.length, Object.keys(configs).length);
|
|
3927
|
+
/** @type {FilesByConfig} */
|
|
3731
3928
|
const filesByConfig = {};
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
if (
|
|
3929
|
+
const configEntries = Object.entries(configs);
|
|
3930
|
+
if (singleConfigMode) {
|
|
3931
|
+
const firstEntry = configEntries[0];
|
|
3932
|
+
if (firstEntry) {
|
|
3933
|
+
const [filepath, config] = firstEntry;
|
|
3736
3934
|
filesByConfig[filepath] = {
|
|
3737
3935
|
config,
|
|
3738
3936
|
files
|
|
3739
3937
|
};
|
|
3740
|
-
break;
|
|
3741
3938
|
}
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
/** This config should match all files since it has a parent glob */
|
|
3749
|
-
const includeAllFiles = Object.keys(config).some((glob) => glob.startsWith(".."));
|
|
3750
|
-
const scopedFiles = new Set(includeAllFiles ? filesSet : void 0);
|
|
3751
|
-
/**
|
|
3752
|
-
* Without a parent glob, if file is inside the config file's directory,
|
|
3753
|
-
* assign it to that configuration.
|
|
3754
|
-
*/
|
|
3755
|
-
if (!includeAllFiles) filesSet.forEach((file) => {
|
|
3756
|
-
if (isInsideDir(file)) scopedFiles.add(file);
|
|
3757
|
-
});
|
|
3758
|
-
/** Files should only match a single config */
|
|
3759
|
-
scopedFiles.forEach((file) => {
|
|
3760
|
-
filesSet.delete(file);
|
|
3761
|
-
});
|
|
3939
|
+
return filesByConfig;
|
|
3940
|
+
}
|
|
3941
|
+
/** @type {Map<string, number>} */
|
|
3942
|
+
const configIndexByDirectory = /* @__PURE__ */ new Map();
|
|
3943
|
+
let firstParentGlobConfigIndex = Infinity;
|
|
3944
|
+
for (const [configIndex, [filepath, config]] of configEntries.entries()) {
|
|
3762
3945
|
filesByConfig[filepath] = {
|
|
3763
3946
|
config,
|
|
3764
|
-
files: [
|
|
3947
|
+
files: []
|
|
3765
3948
|
};
|
|
3949
|
+
const directory = path.dirname(filepath);
|
|
3950
|
+
if (!configIndexByDirectory.has(directory)) configIndexByDirectory.set(directory, configIndex);
|
|
3951
|
+
if (firstParentGlobConfigIndex === Infinity && Object.keys(config).some((glob) => glob.startsWith(".."))) firstParentGlobConfigIndex = configIndex;
|
|
3952
|
+
}
|
|
3953
|
+
/** @type {Map<string, number>} */
|
|
3954
|
+
const containingConfigIndexCache = /* @__PURE__ */ new Map();
|
|
3955
|
+
/**
|
|
3956
|
+
* @param {string} directory
|
|
3957
|
+
* @returns {number}
|
|
3958
|
+
*/
|
|
3959
|
+
const findContainingConfigIndex = (directory) => {
|
|
3960
|
+
const cachedIndex = containingConfigIndexCache.get(directory);
|
|
3961
|
+
if (cachedIndex !== void 0) return cachedIndex;
|
|
3962
|
+
let configIndex = configIndexByDirectory.get(directory) ?? Infinity;
|
|
3963
|
+
const parentDirectory = path.dirname(directory);
|
|
3964
|
+
if (parentDirectory !== directory) configIndex = Math.min(configIndex, findContainingConfigIndex(parentDirectory));
|
|
3965
|
+
containingConfigIndexCache.set(directory, configIndex);
|
|
3966
|
+
return configIndex;
|
|
3967
|
+
};
|
|
3968
|
+
for (const file of new Set(files)) {
|
|
3969
|
+
const containingConfigIndex = findContainingConfigIndex(path.dirname(file.filepath));
|
|
3970
|
+
const configIndex = Math.min(containingConfigIndex, firstParentGlobConfigIndex);
|
|
3971
|
+
if (configIndex !== Infinity) {
|
|
3972
|
+
const [configPath] = configEntries[configIndex];
|
|
3973
|
+
filesByConfig[configPath].files.push(file);
|
|
3974
|
+
}
|
|
3766
3975
|
}
|
|
3767
3976
|
return filesByConfig;
|
|
3768
3977
|
};
|
|
3769
3978
|
//#endregion
|
|
3770
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
3771
|
-
const debugLog$
|
|
3979
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/resolveGitRepo.js
|
|
3980
|
+
const debugLog$5 = createDebug("lint-staged:resolveGitRepo");
|
|
3772
3981
|
/**
|
|
3773
3982
|
* Relative path up to the repo top-level directory
|
|
3774
3983
|
* @example "../"
|
|
@@ -3796,10 +4005,10 @@ const ABSOLUTE_GIT_DIR = "--absolute-git-dir";
|
|
|
3796
4005
|
/** Resolve git directory and possible submodule paths */
|
|
3797
4006
|
const resolveGitRepo = async (cwd = process.cwd()) => {
|
|
3798
4007
|
try {
|
|
3799
|
-
debugLog$
|
|
3800
|
-
debugLog$
|
|
4008
|
+
debugLog$5("Resolving git repo from `%s`", cwd);
|
|
4009
|
+
debugLog$5("Unset GIT_DIR (was `%s`)", process.env.GIT_DIR);
|
|
3801
4010
|
delete process.env.GIT_DIR;
|
|
3802
|
-
debugLog$
|
|
4011
|
+
debugLog$5("Unset GIT_WORK_TREE (was `%s`)", process.env.GIT_WORK_TREE);
|
|
3803
4012
|
delete process.env.GIT_WORK_TREE;
|
|
3804
4013
|
const [relativeTopLevelDir, topLevel, absoluteGitDir] = (await execGit([
|
|
3805
4014
|
"rev-parse",
|
|
@@ -3808,16 +4017,16 @@ const resolveGitRepo = async (cwd = process.cwd()) => {
|
|
|
3808
4017
|
ABSOLUTE_GIT_DIR
|
|
3809
4018
|
], { cwd })).split("\n");
|
|
3810
4019
|
const topLevelDir = normalizePath(path.join(cwd, relativeTopLevelDir));
|
|
3811
|
-
debugLog$
|
|
4020
|
+
debugLog$5("Resolved git repository top-level directory to be `%s`", topLevelDir);
|
|
3812
4021
|
const relativeGitConfigDir = path.relative(topLevel, absoluteGitDir);
|
|
3813
4022
|
const gitConfigDir = normalizePath(path.join(topLevelDir, relativeGitConfigDir));
|
|
3814
|
-
debugLog$
|
|
4023
|
+
debugLog$5("Resolved git config directory to be `%s`", gitConfigDir);
|
|
3815
4024
|
return {
|
|
3816
4025
|
topLevelDir,
|
|
3817
4026
|
gitConfigDir
|
|
3818
4027
|
};
|
|
3819
4028
|
} catch (error) {
|
|
3820
|
-
debugLog$
|
|
4029
|
+
debugLog$5("Failed to resolve git repo with error:", error);
|
|
3821
4030
|
return {
|
|
3822
4031
|
error,
|
|
3823
4032
|
topLevelDir: null,
|
|
@@ -3826,7 +4035,7 @@ const resolveGitRepo = async (cwd = process.cwd()) => {
|
|
|
3826
4035
|
}
|
|
3827
4036
|
};
|
|
3828
4037
|
//#endregion
|
|
3829
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
4038
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/configFiles.js
|
|
3830
4039
|
const CONFIG_NAME = "lint-staged";
|
|
3831
4040
|
const PACKAGE_JSON_FILE = "package.json";
|
|
3832
4041
|
const PACKAGE_YAML_FILES = ["package.yaml", "package.yml"];
|
|
@@ -3855,7 +4064,7 @@ const CONFIG_FILE_NAMES = [
|
|
|
3855
4064
|
"lint-staged.config.cts"
|
|
3856
4065
|
];
|
|
3857
4066
|
//#endregion
|
|
3858
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
4067
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/resolveConfig.js
|
|
3859
4068
|
/**
|
|
3860
4069
|
* require() does not exist for ESM, so we must create it to use require.resolve().
|
|
3861
4070
|
* @see https://nodejs.org/api/module.html#modulecreaterequirefilename
|
|
@@ -3869,9 +4078,9 @@ function resolveConfig(configPath) {
|
|
|
3869
4078
|
}
|
|
3870
4079
|
}
|
|
3871
4080
|
//#endregion
|
|
3872
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
4081
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/loadConfig.js
|
|
3873
4082
|
/** @typedef {import('./index').Logger} Logger */
|
|
3874
|
-
const debugLog$
|
|
4083
|
+
const debugLog$4 = createDebug("lint-staged:loadConfig");
|
|
3875
4084
|
const readFile = async (filename) => fsPromises.readFile(path.resolve(filename), "utf-8");
|
|
3876
4085
|
const jsonParse = async (filename) => {
|
|
3877
4086
|
const isPackageFile = PACKAGE_JSON_FILE.includes(path.basename(filename));
|
|
@@ -3881,7 +4090,7 @@ const jsonParse = async (filename) => {
|
|
|
3881
4090
|
return isPackageFile ? json[CONFIG_NAME] : json;
|
|
3882
4091
|
} catch (error) {
|
|
3883
4092
|
if (path.basename(filename) === "package.json") {
|
|
3884
|
-
debugLog$
|
|
4093
|
+
debugLog$4("Ignoring invalid JSON file %s", filename);
|
|
3885
4094
|
return;
|
|
3886
4095
|
}
|
|
3887
4096
|
throw error;
|
|
@@ -3895,7 +4104,7 @@ const yamlParse = async (filename) => {
|
|
|
3895
4104
|
return isPackageFile ? yaml[CONFIG_NAME] : yaml;
|
|
3896
4105
|
} catch (error) {
|
|
3897
4106
|
if (isPackageFile) {
|
|
3898
|
-
debugLog$
|
|
4107
|
+
debugLog$4("Ignoring invalid YAML file %s", filename);
|
|
3899
4108
|
return;
|
|
3900
4109
|
}
|
|
3901
4110
|
throw error;
|
|
@@ -3933,175 +4142,24 @@ const loadConfigByExt = async (filename) => {
|
|
|
3933
4142
|
/** @param {string} configPath */
|
|
3934
4143
|
const loadConfig = async (configPath, logger) => {
|
|
3935
4144
|
try {
|
|
3936
|
-
debugLog$
|
|
4145
|
+
debugLog$4("Loading configuration from `%s`...", configPath);
|
|
3937
4146
|
const result = await loadConfigByExt(resolveConfig(configPath));
|
|
3938
4147
|
const config = await result.config ?? null;
|
|
3939
4148
|
const filepath = result.filepath;
|
|
3940
|
-
if (config) debugLog$
|
|
3941
|
-
else debugLog$
|
|
4149
|
+
if (config) debugLog$4("Successfully loaded config from `%s`:\n%O", filepath, config);
|
|
4150
|
+
else debugLog$4("Found no config in %s", filepath);
|
|
3942
4151
|
return {
|
|
3943
4152
|
config,
|
|
3944
4153
|
filepath
|
|
3945
4154
|
};
|
|
3946
4155
|
} catch (error) {
|
|
3947
|
-
debugLog$
|
|
4156
|
+
debugLog$4("Failed to load configuration from `%s` with error:\n", configPath, error);
|
|
3948
4157
|
logger.error(failedToLoadConfig(configPath));
|
|
3949
4158
|
return {};
|
|
3950
4159
|
}
|
|
3951
4160
|
};
|
|
3952
4161
|
//#endregion
|
|
3953
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
3954
|
-
/**
|
|
3955
|
-
* A correctly-formed brace expansion must contain unquoted opening and closing braces,
|
|
3956
|
-
* and at least one unquoted comma or a valid sequence expression.
|
|
3957
|
-
* Any incorrectly formed brace expansion is left unchanged.
|
|
3958
|
-
*
|
|
3959
|
-
* @see https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html
|
|
3960
|
-
*
|
|
3961
|
-
* Lint-staged uses `micromatch` for brace expansion, and its behavior is to treat
|
|
3962
|
-
* invalid brace expansions as literal strings, which means they (typically) do not match
|
|
3963
|
-
* anything.
|
|
3964
|
-
*
|
|
3965
|
-
* This RegExp tries to match most cases of invalid brace expansions, so that they can be
|
|
3966
|
-
* detected, warned about, and re-formatted by removing the braces and thus hopefully
|
|
3967
|
-
* matching the files as intended by the user. The only real fix is to remove the incorrect
|
|
3968
|
-
* braces from user configuration, but this is left to the user (after seeing the warning).
|
|
3969
|
-
*
|
|
3970
|
-
* @example <caption>Globs with brace expansions</caption>
|
|
3971
|
-
* - *.{js,tx} // expanded as *.js, *.ts
|
|
3972
|
-
* - *.{{j,t}s,css} // expanded as *.js, *.ts, *.css
|
|
3973
|
-
* - file_{1..10}.css // expanded as file_1.css, file_2.css, …, file_10.css
|
|
3974
|
-
*
|
|
3975
|
-
* @example <caption>Globs with incorrect brace expansions</caption>
|
|
3976
|
-
* - *.{js} // should just be *.js
|
|
3977
|
-
* - *.{js,{ts}} // should just be *.{js,ts}
|
|
3978
|
-
* - *.\{js\} // escaped braces, so they're treated literally
|
|
3979
|
-
* - *.${js} // dollar-sign inhibits expansion, so treated literally
|
|
3980
|
-
* - *.{js\,ts} // the comma is escaped, so treated literally
|
|
3981
|
-
*/
|
|
3982
|
-
const getIncorrectBracesRegexp = () => /(?<![\\$])({)(?:(?!(?<!\\),|\.\.|\{|\}).)*?(?<!\\)(})/g;
|
|
3983
|
-
const BRACE_OPEN_REGEXP = /{/;
|
|
3984
|
-
const BRACE_CLOSE_REGEXP = /}/;
|
|
3985
|
-
/**
|
|
3986
|
-
* @param {string} pattern
|
|
3987
|
-
* @returns {string}
|
|
3988
|
-
*/
|
|
3989
|
-
const stripIncorrectBraces = (pattern) => {
|
|
3990
|
-
let output = `${pattern}`;
|
|
3991
|
-
const regexp = getIncorrectBracesRegexp();
|
|
3992
|
-
let match = regexp.exec(output);
|
|
3993
|
-
while (match) {
|
|
3994
|
-
const fullMatch = match[0];
|
|
3995
|
-
const withoutBraces = fullMatch.replace(BRACE_OPEN_REGEXP, "").replace(BRACE_CLOSE_REGEXP, "");
|
|
3996
|
-
output = output.replace(fullMatch, withoutBraces);
|
|
3997
|
-
regexp.lastIndex = 0;
|
|
3998
|
-
match = regexp.exec(output);
|
|
3999
|
-
}
|
|
4000
|
-
return output;
|
|
4001
|
-
};
|
|
4002
|
-
/**
|
|
4003
|
-
* This RegExp matches "duplicate" opening and closing braces, without any other braces
|
|
4004
|
-
* in between, where the duplication is redundant and should be removed.
|
|
4005
|
-
*
|
|
4006
|
-
* @example *.{{js,ts}} // should just be *.{js,ts}
|
|
4007
|
-
*/
|
|
4008
|
-
const DOUBLE_BRACES_REGEXP = /{{[^}{]*}}/;
|
|
4009
|
-
/**
|
|
4010
|
-
* @param {string} pattern
|
|
4011
|
-
* @returns {string}
|
|
4012
|
-
*/
|
|
4013
|
-
const stripDoubleBraces = (pattern) => {
|
|
4014
|
-
let output = `${pattern}`;
|
|
4015
|
-
const match = DOUBLE_BRACES_REGEXP.exec(pattern)?.[0];
|
|
4016
|
-
if (match) {
|
|
4017
|
-
const withoutBraces = match.replace("{{", "{").replace("}}", "}");
|
|
4018
|
-
output = output.replace(match, withoutBraces);
|
|
4019
|
-
}
|
|
4020
|
-
return output;
|
|
4021
|
-
};
|
|
4022
|
-
/**
|
|
4023
|
-
* Validate and remove incorrect brace expansions from glob pattern.
|
|
4024
|
-
* For example `*.{js}` is incorrect because it doesn't contain a `,` or `..`,
|
|
4025
|
-
* and will be reformatted as `*.js`.
|
|
4026
|
-
*
|
|
4027
|
-
* @param {string} pattern the glob pattern
|
|
4028
|
-
* @param {*} logger
|
|
4029
|
-
* @returns {string}
|
|
4030
|
-
*/
|
|
4031
|
-
const validateBraces = (pattern, logger) => {
|
|
4032
|
-
const fixedPattern = stripDoubleBraces(stripIncorrectBraces(pattern));
|
|
4033
|
-
if (fixedPattern !== pattern) logger.warn(incorrectBraces(pattern, fixedPattern));
|
|
4034
|
-
return fixedPattern;
|
|
4035
|
-
};
|
|
4036
|
-
//#endregion
|
|
4037
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/validateConfig.js
|
|
4038
|
-
/** @typedef {import('./index').Logger} Logger */
|
|
4039
|
-
const debugLog$4 = createDebug("lint-staged:validateConfig");
|
|
4040
|
-
const isTask = (task) => typeof task === "string" || typeof task === "function";
|
|
4041
|
-
const isSequentialTasks = (tasks) => tasks.every((task) => {
|
|
4042
|
-
if (Array.isArray(task)) return task.every(isTask);
|
|
4043
|
-
else return isTask(task);
|
|
4044
|
-
});
|
|
4045
|
-
const validateConfigLogic = (config, configPath, logger) => {
|
|
4046
|
-
debugLog$4("Validating config from `%s`...", configPath);
|
|
4047
|
-
if (!config || typeof config !== "object" && typeof config !== "function") throw ConfigFormatError;
|
|
4048
|
-
/**
|
|
4049
|
-
* Function configurations receive all staged files as their argument.
|
|
4050
|
-
* They are not further validated here to make sure the function gets
|
|
4051
|
-
* evaluated only once.
|
|
4052
|
-
*
|
|
4053
|
-
* @see getSpawnedTasks
|
|
4054
|
-
*/
|
|
4055
|
-
if (typeof config === "function") return { "*": config };
|
|
4056
|
-
if (Object.entries(config).length === 0) throw ConfigEmptyError;
|
|
4057
|
-
const errors = [];
|
|
4058
|
-
/**
|
|
4059
|
-
* Create a new validated config because the keys (patterns) might change.
|
|
4060
|
-
* Since the Object.reduce method already loops through each entry in the config,
|
|
4061
|
-
* it can be used for validating the values at the same time.
|
|
4062
|
-
*/
|
|
4063
|
-
const validatedConfig = Object.entries(config).reduce((collection, [pattern, task]) => {
|
|
4064
|
-
if (Array.isArray(task)) {
|
|
4065
|
-
if (!isSequentialTasks(task)) errors.push(configurationError(pattern, "Should be an array of strings or functions, or single-level nested array or strings of functions.", task));
|
|
4066
|
-
} else if (typeof task === "object") {
|
|
4067
|
-
/** Invalid function task */
|
|
4068
|
-
if (typeof task.title !== "string" || typeof task.task !== "function") errors.push(configurationError(pattern, "Function task should contain `title` and `task` fields, where `title` should be a string and `task` should be a function.", task));
|
|
4069
|
-
} else if (typeof task !== "string" && typeof task !== "function")
|
|
4070
|
-
/** Singular invalid value */
|
|
4071
|
-
errors.push(configurationError(pattern, "Should be a string, a function, an object or an array of strings and functions.", task));
|
|
4072
|
-
/**
|
|
4073
|
-
* A typical configuration error is using invalid brace expansion, like `*.{js}`.
|
|
4074
|
-
* These are automatically fixed and warned about.
|
|
4075
|
-
*/
|
|
4076
|
-
const fixedPattern = validateBraces(pattern, logger);
|
|
4077
|
-
return Object.assign(collection, { [fixedPattern]: task });
|
|
4078
|
-
}, {});
|
|
4079
|
-
if (errors.length) {
|
|
4080
|
-
const message = errors.join("\n\n");
|
|
4081
|
-
logger.error(failedToParseConfig(configPath, message));
|
|
4082
|
-
throw new Error(message);
|
|
4083
|
-
}
|
|
4084
|
-
debugLog$4("Validated config from `%s`:", configPath);
|
|
4085
|
-
debugLog$4(inspect(config, { compact: false }));
|
|
4086
|
-
return validatedConfig;
|
|
4087
|
-
};
|
|
4088
|
-
/**
|
|
4089
|
-
* Runs config validation. Throws error if the config is not valid.
|
|
4090
|
-
* @param {Object} config
|
|
4091
|
-
* @param {string} configPath
|
|
4092
|
-
* @param {Logger} logger
|
|
4093
|
-
* @returns {Object} config
|
|
4094
|
-
*/
|
|
4095
|
-
const validateConfig = (config, configPath, logger) => {
|
|
4096
|
-
try {
|
|
4097
|
-
return validateConfigLogic(config, configPath, logger);
|
|
4098
|
-
} catch (error) {
|
|
4099
|
-
logger.error(failedToParseConfig(configPath, error));
|
|
4100
|
-
throw error;
|
|
4101
|
-
}
|
|
4102
|
-
};
|
|
4103
|
-
//#endregion
|
|
4104
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/searchConfigs.js
|
|
4162
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/searchConfigs.js
|
|
4105
4163
|
const debugLog$3 = createDebug("lint-staged:searchConfigs");
|
|
4106
4164
|
const CONFIG_PATHSPEC = CONFIG_FILE_NAMES.map((f) => `:(glob)**/${f}`);
|
|
4107
4165
|
const numberOfLevels = (file) => file.split("/").length;
|
|
@@ -4173,7 +4231,7 @@ const listConfigFilesFromFs = async ({ cwd }) => {
|
|
|
4173
4231
|
* @param {string} [options.topLevelDir] - Top-level directory of the git repo
|
|
4174
4232
|
* @param {import('./index').Logger} logger
|
|
4175
4233
|
*
|
|
4176
|
-
* @returns {Promise<
|
|
4234
|
+
* @returns {Promise<Record<string, import('./config.js').Configuration>>} found configs with filepath as key, and config as value
|
|
4177
4235
|
*/
|
|
4178
4236
|
const searchConfigs = async ({ configObject, configPath, cwd = process.cwd(), topLevelDir = cwd }, logger) => {
|
|
4179
4237
|
debugLog$3("Searching for configuration files...");
|
|
@@ -4215,7 +4273,7 @@ const searchConfigs = async ({ configObject, configPath, cwd = process.cwd(), to
|
|
|
4215
4273
|
return foundConfigs;
|
|
4216
4274
|
};
|
|
4217
4275
|
//#endregion
|
|
4218
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
4276
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/runAll.js
|
|
4219
4277
|
/** @typedef {import('./index').Logger} Logger */
|
|
4220
4278
|
const debugLog$2 = createDebug("lint-staged:runAll");
|
|
4221
4279
|
/**
|
|
@@ -4331,8 +4389,6 @@ const runAll = async ({ all, allowEmpty, concurrent, configObject, configPath, c
|
|
|
4331
4389
|
const hasMultipleConfigs = numberOfConfigs > 1;
|
|
4332
4390
|
let hasDeprecatedGitAdd = false;
|
|
4333
4391
|
const tasks = [];
|
|
4334
|
-
/** @type {Set<import('./getStagedFiles.js').StagedFile>} */
|
|
4335
|
-
const matchedFiles = /* @__PURE__ */ new Set();
|
|
4336
4392
|
const abortController = getAbortController();
|
|
4337
4393
|
for (const [groupConfigPath, { config, files }] of Object.entries(filesByConfig)) {
|
|
4338
4394
|
const configName = groupConfigPath ? normalizePath(path.relative(cwd, groupConfigPath)) : "Config object";
|
|
@@ -4346,7 +4402,8 @@ const runAll = async ({ all, allowEmpty, concurrent, configObject, configPath, c
|
|
|
4346
4402
|
abortController,
|
|
4347
4403
|
command: task.commands,
|
|
4348
4404
|
continueOnError,
|
|
4349
|
-
files: task.fileList
|
|
4405
|
+
files: task.fileList,
|
|
4406
|
+
verbose
|
|
4350
4407
|
}) : getSpawnedTasks({
|
|
4351
4408
|
abortController,
|
|
4352
4409
|
commands: task.commands,
|
|
@@ -4357,13 +4414,6 @@ const runAll = async ({ all, allowEmpty, concurrent, configObject, configPath, c
|
|
|
4357
4414
|
topLevelDir,
|
|
4358
4415
|
verbose
|
|
4359
4416
|
})).then((subTasks) => {
|
|
4360
|
-
task.fileList.forEach((file) => {
|
|
4361
|
-
const normalizedFile = path.isAbsolute(file.filepath) ? file : {
|
|
4362
|
-
filepath: normalizePath(path.join(groupCwd, file.filepath)),
|
|
4363
|
-
status: file.status
|
|
4364
|
-
};
|
|
4365
|
-
matchedFiles.add(normalizedFile);
|
|
4366
|
-
});
|
|
4367
4417
|
const includesGitAdd = (subTask) => subTask.title.includes("git add");
|
|
4368
4418
|
hasDeprecatedGitAdd = hasDeprecatedGitAdd || subTasks.some((subTask) => Array.isArray(subTask) ? subTask.some(includesGitAdd) : includesGitAdd(subTask));
|
|
4369
4419
|
const fileCount = task.fileList.length;
|
|
@@ -4397,7 +4447,6 @@ const runAll = async ({ all, allowEmpty, concurrent, configObject, configPath, c
|
|
|
4397
4447
|
failOnChanges,
|
|
4398
4448
|
gitConfigDir,
|
|
4399
4449
|
logger: thisLogger,
|
|
4400
|
-
matchedFiles,
|
|
4401
4450
|
maxArgLength,
|
|
4402
4451
|
topLevelDir
|
|
4403
4452
|
});
|
|
@@ -4430,7 +4479,7 @@ const runAll = async ({ all, allowEmpty, concurrent, configObject, configPath, c
|
|
|
4430
4479
|
return ctx;
|
|
4431
4480
|
};
|
|
4432
4481
|
//#endregion
|
|
4433
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
4482
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/validateOptions.js
|
|
4434
4483
|
const debugLog$1 = createDebug("lint-staged:validateOptions");
|
|
4435
4484
|
/** @type {(value: number) => boolean} */
|
|
4436
4485
|
const isValidIntegerValue = (value) => Number.isInteger(value) || value === Infinity;
|
|
@@ -4463,10 +4512,10 @@ const validateOptions = async (options = {}, logger) => {
|
|
|
4463
4512
|
debugLog$1("Validated options: %o", options);
|
|
4464
4513
|
};
|
|
4465
4514
|
//#endregion
|
|
4466
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
4467
|
-
const getVersion = async () => "17.
|
|
4515
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/version.js
|
|
4516
|
+
const getVersion = async () => "17.6.0";
|
|
4468
4517
|
//#endregion
|
|
4469
|
-
//#region ../../node_modules/.pnpm/lint-staged@17.
|
|
4518
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.6.0/node_modules/lint-staged/lib/index.js
|
|
4470
4519
|
const debugLog = createDebug("lint-staged");
|
|
4471
4520
|
/**
|
|
4472
4521
|
* @typedef {(...any) => void} LogFunction
|