ShtukbaseStandard
archivo del paquete→ .shtukbase/packages/collections/checks/lib/runner.ts

checks/lib/runner.ts

12 líneas, 785 B.

El archivo tal como está en el paquete: el código y sus comentarios no se traducen.

  1. // Runs one schema rule as a package action. The working directory is the project root.
  2. // Each finding is one line on stdout, in English, naming the record. Exit 0: the norm holds (a rule with nothing to
  3. // check holds too). Exit 1: findings or a schema error.
  4. import { type Rule, Project, runRule } from './speclib.ts';
  5. /** Runs the rule on the project in `root` (default: the working directory); prints the findings and sets the exit code. */
  6. export function main(mod: Rule, root: string = process.cwd()): void {
  7. const res = runRule(mod, new Project(root));
  8. const lines = res.error ? [`schema error: ${res.error}`] : res.holes.map((h) => `${h.record}: ${h.missing} → ${h.fix}`);
  9. if (lines.length) console.log(lines.join('\n'));
  10. process.exitCode = lines.length ? 1 : 0;
  11. }