murashit_codex-panel/scripts/check.mjs

43 lines
1.5 KiB
JavaScript
Raw Normal View History

2026-05-30 01:01:34 +00:00
import { spawnSync } from "node:child_process";
const args = new Set(process.argv.slice(2));
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
2026-06-07 05:00:27 +00:00
const checks = [
{ local: "typecheck", ci: "typecheck:ci", localPhase: "parallel" },
{ local: "test", ci: "test:ci", localPhase: "parallel" },
2026-06-16 03:58:55 +00:00
{ local: "lint", ci: "lint:ci", localPhase: "parallel" },
2026-06-07 05:00:27 +00:00
{ local: "format:check", ci: "format:check:ci", localPhase: "parallel" },
{ local: "build:styles:check", ci: "build:styles:check", localPhase: "parallel" },
{ local: "build", ci: "build", localPhase: "sequential" },
];
2026-05-30 01:01:34 +00:00
for (const arg of args) {
if (arg !== "--ci") {
console.error("Usage: node scripts/check.mjs [--ci]");
process.exit(1);
}
}
if (args.has("--ci")) {
2026-06-11 09:23:15 +00:00
for (const check of checks) {
if (check.ci === null) continue;
run(npmCommand, ["run", check.ci]);
}
2026-05-30 01:01:34 +00:00
} else {
2026-06-07 05:00:27 +00:00
const parallelScripts = checks.filter((check) => check.localPhase === "parallel").map((check) => check.local);
run("node", ["scripts/run-parallel.mjs", ...parallelScripts]);
for (const check of checks.filter((check) => check.localPhase === "sequential")) run(npmCommand, ["run", check.local]);
2026-05-30 01:01:34 +00:00
}
function run(command, args) {
const result = spawnSync(command, args, {
stdio: "inherit",
shell: false,
});
if (result.error) {
console.error(`Failed to run ${command} ${args.join(" ")}: ${result.error.message}`);
process.exit(1);
}
if (result.status !== 0) process.exit(result.status ?? 1);
}