first refactor
This commit is contained in:
parent
1f5dac28c7
commit
588f666943
84 changed files with 996 additions and 1062 deletions
42
scripts/check.ts
Normal file
42
scripts/check.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/** Run every repository gate and report failures without hiding later checks. */
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
export const checks = [
|
||||
'build',
|
||||
'typecheck',
|
||||
'test:contracts',
|
||||
'test:tooling',
|
||||
'lint:check',
|
||||
] as const;
|
||||
|
||||
async function runTask(check: string): Promise<number> {
|
||||
process.stdout.write(`\nRunning ${check}\n`);
|
||||
const child = Bun.spawn([process.execPath, 'run', check], {
|
||||
cwd: fileURLToPath(new URL('..', import.meta.url)),
|
||||
stdin: 'inherit',
|
||||
stdout: 'inherit',
|
||||
stderr: 'inherit',
|
||||
});
|
||||
return child.exited;
|
||||
}
|
||||
|
||||
export async function runChecks(
|
||||
tasks: readonly string[] = checks,
|
||||
run: (task: string) => Promise<number> = runTask
|
||||
): Promise<string[]> {
|
||||
const failed: string[] = [];
|
||||
for (const task of tasks) {
|
||||
if ((await run(task)) !== 0) failed.push(task);
|
||||
}
|
||||
return failed;
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
const failed = await runChecks();
|
||||
if (failed.length > 0) {
|
||||
process.stderr.write(`\nFailed checks: ${failed.join(', ')}\n`);
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
process.stdout.write('\nAll repository checks passed.\n');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue