mirror of
https://github.com/nexu-io/open-design.git
synced 2026-09-20 06:15:06 +08:00
26 lines
594 B
TypeScript
26 lines
594 B
TypeScript
export type GuardContext = {
|
|
repoRoot: string;
|
|
};
|
|
|
|
export type GuardCheck = {
|
|
name: string;
|
|
run: (context: GuardContext) => boolean | Promise<boolean>;
|
|
};
|
|
|
|
export async function runGuardChecks(
|
|
checks: readonly GuardCheck[],
|
|
context: GuardContext,
|
|
): Promise<boolean> {
|
|
const results: boolean[] = [];
|
|
for (const check of checks) {
|
|
try {
|
|
results.push(await check.run(context));
|
|
} catch (error) {
|
|
console.error(`Guard check failed unexpectedly: ${check.name}`);
|
|
console.error(error);
|
|
results.push(false);
|
|
}
|
|
}
|
|
return results.every(Boolean);
|
|
}
|