mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-29 21:29:48 +08:00
fix: use spawnSync for autocorrect command
This commit is contained in:
@@ -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;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user