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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | #!/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, findFiles } from './lib/file-utils.js';
import { generateHtmlDiff, generateIndexHtml, generateTextReport } from './lib/html-report.js';
import { compareOutput, loadConfig, resolveConfigPath } from './compare-output-core.js';
import { compareOutputPatchPairs } from './compare-output-patch-pairs.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',
})
.option('added-since', {
type: 'string',
description:
'Patch-pairs mode only. Git ref to scope pairs to families introduced by the current release (e.g. core-262-patch). Overrides config.addedSince.',
})
.help()
.argv;
export async function runCompareOutputCli() {
try {
const configPath = resolveConfigPath(argv.config);
const config = await loadConfig(configPath);
const result = config.mode === 'patch-pairs'
? await compareOutputPatchPairs(argv, {
deps: {
compareFiles,
findFiles,
generateHtmlDiff,
generateIndexHtml,
generateTextReport,
},
})
: 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();
}
|