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 {
try {
execSync(`npx autocorrect-node --fix "${filePath}"`, { stdio: "inherit" });
return true;
} catch {
return false;
}
const npxCmd = process.platform === "win32" ? "npx.cmd" : "npx";
const result = spawnSync(npxCmd, ["autocorrect-node", "--fix", filePath], {
stdio: "inherit",
});
return result.status === 0;
}