包文件→ .shtukbase/packages/collections/checks/lib/runner.ts
checks/lib/runner.ts
12 行, 785 B.
文件按包中的原样显示:代码及其注释不做翻译。
- // Runs one schema rule as a package action. The working directory is the project root.
- // Each finding is one line on stdout, in English, naming the record. Exit 0: the norm holds (a rule with nothing to
- // check holds too). Exit 1: findings or a schema error.
- import { type Rule, Project, runRule } from './speclib.ts';
- /** Runs the rule on the project in `root` (default: the working directory); prints the findings and sets the exit code. */
- export function main(mod: Rule, root: string = process.cwd()): void {
- const res = runRule(mod, new Project(root));
- const lines = res.error ? [`schema error: ${res.error}`] : res.holes.map((h) => `${h.record}: ${h.missing} → ${h.fix}`);
- if (lines.length) console.log(lines.join('\n'));
- process.exitCode = lines.length ? 1 : 0;
- }