Reduce repeated compiler startup in monorepo QX formatting

This commit is contained in:
Timothy J. Aveni
2026-10-13 05:37:58 -07:00
parent e92b08025c
commit 85163b6e67
2 changed files with 79 additions and 0 deletions
+24
View File
@@ -595,6 +595,30 @@ const main = async () => {
process.stdout.write(`${JSON.stringify(plan, null, 2)}\n`);
return;
}
if (command === "format" && (args[0] === "--check" || args[0] === "--write")) {
const check = args[0] === "--check",
files = args.slice(1);
if (!files.length || files.some((file) => file.startsWith("-")))
throw new Error("usage: quixos-qx format --check|--write FILE...");
for (const file of files) {
try {
const source = await readFile(file, "utf8"),
formatted = formatQx(source);
if (formatted === source) continue;
if (check) {
console.error(`Needs formatting: ${file}`);
process.exitCode = 1;
} else {
await writeFile(file, formatted);
console.log(`Formatted ${file}`);
}
} catch (error) {
console.error(`${file}: ${error instanceof Error ? error.message : error}`);
process.exitCode = 1;
}
}
return;
}
const [file, flag, ...rest] = args;
if (
!file ||