mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 01:38:07 +08:00
DISABLE_THIRD_PARTY_CHECK=Adding istanbul-diff to node_modules Bug: chromium:1044881 Change-Id: Ia80f499622132ce9b2c0890147fecdd4530886c7 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2024871 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Mathias Bynens <mathias@chromium.org>
71 lines
2.4 KiB
JavaScript
Executable File
71 lines
2.4 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
var
|
|
argv = require('minimist')(process.argv.slice(2)),
|
|
istanbulDiff = require('../lib/index.js'),
|
|
fs = require('fs'),
|
|
depth = argv.depth,
|
|
pick = argv.pick,
|
|
args = argv._;
|
|
|
|
// console.log(argv, depth);
|
|
|
|
if (args.length !== 1 && args.length !== 2) {
|
|
console.log('Usage: \n istanbul-diff coverage-summary-before.json coverage-summary-after.json');
|
|
console.log('');
|
|
console.log('Options:');
|
|
console.log(' --depth <n> diff to depth n');
|
|
console.log(' --pick <t> pick out <t> diff, e.g. lines.pct (comma separated)');
|
|
console.log(' --lines include linesCovered (can be very long)');
|
|
console.log(' --json output json diff (always exits successfully)');
|
|
console.log(' --json-compact output compact json diff (always exits successfully)');
|
|
console.log(' --detail [<w>] detailed report. <w>=lines,statements,functions,branches or blank for all');
|
|
console.log(' --recurse recurse through sub folders (up to depth), otherwise print only root');
|
|
console.log('');
|
|
console.log(' --nomotivate disabling compliment, or not!');
|
|
console.log(' --nocolor disable colorized output');
|
|
console.log(' --nofail do not exit with code 1 if coverage decreases');
|
|
console.log(' --brief suppress no-change messages');
|
|
console.log('If only one file is give, summarizes coverage for that file.');
|
|
return;
|
|
}
|
|
|
|
if (pick) {
|
|
pick = pick.split(',');
|
|
}
|
|
|
|
var fileLeft = args[0],
|
|
fileRight = args[1],
|
|
options = {
|
|
ignoreLinesCovered: !argv.lines,
|
|
depth : depth,
|
|
pick : pick,
|
|
nomotivate : argv.nomotivate,
|
|
detail : !pick && argv.detail, // pick and detail don't work well together
|
|
nocolor : argv.nocolor,
|
|
recurse : argv.recurse,
|
|
brief : argv.brief,
|
|
single : !fileRight
|
|
},
|
|
left = JSON.parse(fs.readFileSync(fileLeft)),
|
|
right = fileRight && JSON.parse(fs.readFileSync(fileRight)),
|
|
delta = istanbulDiff.diff(left, right, options),
|
|
result;
|
|
// console.log(delta)
|
|
|
|
if (argv.json) {
|
|
console.log(JSON.stringify(delta, null, 2));
|
|
} else if (argv['json-compact']) {
|
|
console.log(JSON.stringify(delta, null, 0));
|
|
} else {
|
|
result = istanbulDiff.print(delta, options);
|
|
console.log(result.msg);
|
|
|
|
if (options.motivate && options.detail === true) {
|
|
console.log(istanbulDiff.print.compliment(!result.regressed));
|
|
}
|
|
if (!argv.nofail && result.regressed) {
|
|
process.exit(1);
|
|
}
|
|
}
|