Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/usr/bin/env node
/**
* Compare output against baseline
* Usage: node compare-output.js --config <config-file> [options]
*/
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import chalk from 'chalk';
import yargs from 'yargs';
import { readManifest, compareFiles, getAllFiles } from './lib/file-utils.js';
import { generateHtmlDiff, generateIndexHtml, generateTextReport } from './lib/html-report.js';
import { compareOutput } from './compare-output-core.js';
// Parse command line arguments
const argv = yargs(process.argv.slice(2))
.option('config', {
alias: 'c',
type: 'string',
description: 'Path to validation config file',
demandOption: true,
})
.option('source', {
alias: 's',
type: 'string',
description: 'Override source path from config',
})
.option('fail-on-diff', {
type: 'boolean',
description: 'Exit with code 1 if differences found',
})
.help()
.argv;
export async function runCompareOutputCli() {
try {
const result = await compareOutput(argv, {
deps: {
readManifest,
compareFiles,
getAllFiles,
generateHtmlDiff,
generateIndexHtml,
generateTextReport,
},
});
if (result.shouldFailExit) {
process.exit(1);
}
} catch (error) {
console.error(chalk.red('❌ Error comparing output:'), error);
process.exit(1);
}
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
runCompareOutputCli();
}
|