Expose local check output

This commit is contained in:
murashit 2026-05-31 11:25:19 +09:00
parent 9c2fdfc574
commit 8e33996dd1
2 changed files with 11 additions and 10 deletions

View file

@ -30,8 +30,8 @@
"release:check": "node scripts/release/check.mjs",
"release:preflight": "node scripts/release/preflight.mjs",
"release:prepare": "node scripts/release/prepare.mjs",
"test": "vitest run --cache",
"test:ci": "vitest run",
"test": "vitest run --cache --reporter=verbose",
"test:ci": "vitest run --reporter=verbose",
"typecheck": "tsc -p tsconfig.json --noEmit --incremental --tsBuildInfoFile node_modules/.cache/typescript/tsconfig.tsbuildinfo",
"typecheck:ci": "tsc -p tsconfig.json --noEmit",
"check": "node scripts/check.mjs",

View file

@ -21,6 +21,12 @@ function prefixedOutput(script, text) {
.join("\n");
}
function flushOutput(script, output) {
const text = Buffer.concat(output).toString();
if (!text.trim()) return;
process.stdout.write(`${prefixedOutput(script, text)}\n`);
}
function runScript(script) {
const startedAt = process.hrtime.bigint();
console.log(`[${script.padEnd(longestNameLength)}] started`);
@ -43,16 +49,17 @@ function runScript(script) {
child.on("close", (code, signal) => {
running.delete(child);
flushOutput(script, output);
const elapsedMs = Number(process.hrtime.bigint() - startedAt) / 1_000_000;
const elapsedSeconds = (elapsedMs / 1000).toFixed(1);
if (code === 0) {
console.log(`[${script.padEnd(longestNameLength)}] passed in ${elapsedSeconds}s`);
resolve({ script, status: 0, output: Buffer.concat(output).toString() });
resolve({ script, status: 0 });
} else {
const detail = signal ? `signal ${signal}` : `exit ${code ?? 1}`;
console.error(`[${script.padEnd(longestNameLength)}] failed with ${detail} after ${elapsedSeconds}s`);
resolve({ script, status: code ?? 1, output: Buffer.concat(output).toString() });
resolve({ script, status: code ?? 1 });
}
});
});
@ -76,12 +83,6 @@ const results = await Promise.all(scripts.map(runScript));
const failed = results.filter((result) => result.status !== 0);
if (failed.length > 0) {
for (const result of failed) {
if (!result.output.trim()) continue;
console.error(`\nOutput from ${result.script}:`);
console.error(prefixedOutput(result.script, result.output));
}
console.error(`Failed checks: ${failed.map((result) => result.script).join(", ")}`);
process.exit(1);
}