From 38ecfa44710db483f38f54436e90a13af099583c Mon Sep 17 00:00:00 2001 From: Tak hoffman Date: Tue, 27 Jan 2026 20:47:56 -0600 Subject: [PATCH] Chore: fix pre-commit formatter batching --- scripts/format-staged.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/scripts/format-staged.js b/scripts/format-staged.js index 346d67389..62bca3d1e 100644 --- a/scripts/format-staged.js +++ b/scripts/format-staged.js @@ -80,18 +80,33 @@ function getGitPaths(args, repoRoot) { function formatFiles(repoRoot, oxfmt, files) { const useShell = process.platform === "win32" && /\.cmd$/i.test(oxfmt.command); - const result = spawnSync(oxfmt.command, ["--write", ...oxfmt.args, ...files], { - cwd: repoRoot, - stdio: "inherit", - shell: useShell, - }); - return result.status === 0; + const MAX_BATCH = 100; + for (let i = 0; i < files.length; i += MAX_BATCH) { + const batch = files.slice(i, i + MAX_BATCH); + const result = spawnSync(oxfmt.command, ["--write", ...oxfmt.args, ...batch], { + cwd: repoRoot, + stdio: "inherit", + shell: useShell, + }); + if (result.status !== 0) { + return false; + } + } + return true; } function stageFiles(repoRoot, files) { if (files.length === 0) return true; - const result = runGitCommand(["add", "--", ...files], { cwd: repoRoot, stdio: "inherit" }); - return result.status === 0; + const MAX_BATCH = 200; + 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() {