mirror of
https://github.com/Xevion/xevion.dev.git
synced 2026-01-31 02:26:38 -06:00
feat: parallelize check tasks with real-time progress output
This commit is contained in:
@@ -3,12 +3,67 @@ set dotenv-load
|
||||
default:
|
||||
just --list
|
||||
|
||||
[script("bun")]
|
||||
check:
|
||||
bun run --cwd web format
|
||||
bun run --cwd web lint
|
||||
bun run --cwd web check
|
||||
cargo clippy --all-targets
|
||||
cargo fmt --check
|
||||
const checks = [
|
||||
{ name: "prettier", cmd: ["bun", "run", "--cwd", "web", "format:check"] },
|
||||
{ name: "eslint", cmd: ["bun", "run", "--cwd", "web", "lint"] },
|
||||
{ name: "svelte-check", cmd: ["bun", "run", "--cwd", "web", "check"] },
|
||||
{ name: "clippy", cmd: ["cargo", "clippy", "--all-targets"] },
|
||||
{ name: "rustfmt", cmd: ["cargo", "fmt", "--check"] },
|
||||
];
|
||||
|
||||
const start = Date.now();
|
||||
const remaining = new Set(checks.map(c => c.name));
|
||||
const results = [];
|
||||
|
||||
// Spawn all checks in parallel
|
||||
const promises = checks.map(async (check) => {
|
||||
const proc = Bun.spawn(check.cmd, {
|
||||
env: { ...process.env, FORCE_COLOR: "1" },
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
});
|
||||
|
||||
const [stdout, stderr] = await Promise.all([
|
||||
new Response(proc.stdout).text(),
|
||||
new Response(proc.stderr).text(),
|
||||
]);
|
||||
|
||||
await proc.exited;
|
||||
const elapsed = ((Date.now() - start) / 1000).toFixed(1);
|
||||
|
||||
return { ...check, stdout, stderr, exitCode: proc.exitCode, elapsed };
|
||||
});
|
||||
|
||||
// Progress updater
|
||||
const interval = setInterval(() => {
|
||||
const elapsed = ((Date.now() - start) / 1000).toFixed(1);
|
||||
const tasks = Array.from(remaining).join(", ");
|
||||
process.stderr.write(`\r\x1b[K${elapsed}s [${tasks}]`);
|
||||
}, 100);
|
||||
|
||||
// Stream outputs as they complete
|
||||
let anyFailed = false;
|
||||
for (const promise of promises) {
|
||||
const result = await promise;
|
||||
remaining.delete(result.name);
|
||||
|
||||
if (result.exitCode !== 0) {
|
||||
anyFailed = true;
|
||||
process.stderr.write(`\r\x1b[K`);
|
||||
process.stdout.write(`❌ ${result.name} (${result.elapsed}s)\n`);
|
||||
if (result.stdout) process.stdout.write(result.stdout);
|
||||
if (result.stderr) process.stderr.write(result.stderr);
|
||||
} else {
|
||||
process.stderr.write(`\r\x1b[K`);
|
||||
process.stdout.write(`✅ ${result.name} (${result.elapsed}s)\n`);
|
||||
}
|
||||
}
|
||||
|
||||
clearInterval(interval);
|
||||
process.stderr.write(`\r\x1b[K`);
|
||||
process.exit(anyFailed ? 1 : 0);
|
||||
|
||||
build:
|
||||
bun run --cwd web build
|
||||
|
||||
Reference in New Issue
Block a user