()
| 61 | } |
| 62 | |
| 63 | function main() { |
| 64 | const args = parseArgs(process.argv); |
| 65 | if (args.help || !args.file) { |
| 66 | process.stdout.write(`${usage()}\n`); |
| 67 | process.exitCode = args.help ? 0 : 2; |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | const filePath = path.resolve(args.projectRoot, args.file); |
| 72 | const markdown = fs.readFileSync(filePath, 'utf8'); |
| 73 | const report = validateExitEvidence(markdown, { |
| 74 | projectRoot: args.projectRoot, |
| 75 | target: args.target, |
| 76 | }); |
| 77 | const pass = report.pass && (args.allowMissing || !report.missingDeclarations); |
| 78 | |
| 79 | if (args.writeRepair && report.failures.length > 0) { |
| 80 | fs.writeFileSync(filePath, appendRepairTasks(markdown, report.failures), 'utf8'); |
| 81 | } |
| 82 | |
| 83 | if (args.json) process.stdout.write(`${JSON.stringify({ ...report, pass }, null, 2)}\n`); |
| 84 | else process.stdout.write(render(args.file, { ...report, pass })); |
| 85 | process.exitCode = pass ? 0 : 1; |
| 86 | } |
| 87 | |
| 88 | if (require.main === module) { |
| 89 | main(); |
no test coverage detected