Chore: fix pre-commit formatter batching
This commit is contained in:
parent
290bbc0ea0
commit
38ecfa4471
@ -80,18 +80,33 @@ function getGitPaths(args, repoRoot) {
|
|||||||
|
|
||||||
function formatFiles(repoRoot, oxfmt, files) {
|
function formatFiles(repoRoot, oxfmt, files) {
|
||||||
const useShell = process.platform === "win32" && /\.cmd$/i.test(oxfmt.command);
|
const useShell = process.platform === "win32" && /\.cmd$/i.test(oxfmt.command);
|
||||||
const result = spawnSync(oxfmt.command, ["--write", ...oxfmt.args, ...files], {
|
const MAX_BATCH = 100;
|
||||||
cwd: repoRoot,
|
for (let i = 0; i < files.length; i += MAX_BATCH) {
|
||||||
stdio: "inherit",
|
const batch = files.slice(i, i + MAX_BATCH);
|
||||||
shell: useShell,
|
const result = spawnSync(oxfmt.command, ["--write", ...oxfmt.args, ...batch], {
|
||||||
});
|
cwd: repoRoot,
|
||||||
return result.status === 0;
|
stdio: "inherit",
|
||||||
|
shell: useShell,
|
||||||
|
});
|
||||||
|
if (result.status !== 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stageFiles(repoRoot, files) {
|
function stageFiles(repoRoot, files) {
|
||||||
if (files.length === 0) return true;
|
if (files.length === 0) return true;
|
||||||
const result = runGitCommand(["add", "--", ...files], { cwd: repoRoot, stdio: "inherit" });
|
const MAX_BATCH = 200;
|
||||||
return result.status === 0;
|
for (let i = 0; i < files.length; i += MAX_BATCH) {
|
||||||
|
const batch = files.slice(i, i + MAX_BATCH);
|
||||||
|
const result = runGitCommand(["add", "--", ...batch], {
|
||||||
|
cwd: repoRoot,
|
||||||
|
stdio: "inherit",
|
||||||
|
});
|
||||||
|
if (result.status !== 0) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user