murashit_codex-panel/scripts/check.mjs

33 lines
993 B
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";
for (const arg of args) {
if (arg !== "--ci") {
console.error("Usage: node scripts/check.mjs [--ci]");
process.exit(1);
}
}
if (args.has("--ci")) {
2026-05-30 02:00:08 +00:00
for (const script of ["typecheck:ci", "test:ci", "lint:ts:ci", "lint:css", "format:check:ci", "build:styles:check", "build"]) {
2026-05-30 01:01:34 +00:00
run(npmCommand, ["run", script]);
}
} else {
2026-05-30 02:00:08 +00:00
run("node", ["scripts/run-parallel.mjs", "typecheck", "test", "lint:ts", "lint:css", "format:check", "build:styles:check"]);
run(npmCommand, ["run", "build"]);
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);
}