fix: use spawnSync for autocorrect command

This commit is contained in:
luojiyin
2026-03-08 20:34:35 +08:00
parent f6cef6bcbb
commit 709e026be1
@@ -1,10 +1,10 @@
import { execSync } from "child_process"; import { spawnSync } from "node:child_process";
import process from "node:process";
export function applyAutocorrect(filePath: string): boolean { export function applyAutocorrect(filePath: string): boolean {
try { const npxCmd = process.platform === "win32" ? "npx.cmd" : "npx";
execSync(`npx autocorrect-node --fix "${filePath}"`, { stdio: "inherit" }); const result = spawnSync(npxCmd, ["autocorrect-node", "--fix", filePath], {
return true; stdio: "inherit",
} catch { });
return false; return result.status === 0;
}
} }