| 1 |
'use strict' |
| 2 |
|
| 3 |
const NYC = require('../../index.js') |
| 4 |
const { cliWrapper, suppressEPIPE, setupOptions } = require('./helpers.js') |
| 5 |
|
| 6 |
exports.command = 'report' |
| 7 |
|
| 8 |
exports.describe = 'run coverage report for .nyc_output' |
| 9 |
|
| 10 |
exports.builder = function (yargs) { |
| 11 |
yargs |
| 12 |
.demandCommand(0, 0) |
| 13 |
.example('$0 report --reporter=lcov', 'output an HTML lcov report to ./coverage') |
| 14 |
|
| 15 |
setupOptions(yargs, 'report') |
| 16 |
} |
| 17 |
|
| 18 |
exports.handler = cliWrapper(async argv => { |
| 19 |
process.env.NYC_CWD = process.cwd() |
| 20 |
var nyc = new NYC(argv) |
| 21 |
await nyc.report().catch(suppressEPIPE) |
| 22 |
if (argv.checkCoverage) { |
| 23 |
await nyc.checkCoverage({ |
| 24 |
lines: argv.lines, |
| 25 |
functions: argv.functions, |
| 26 |
branches: argv.branches, |
| 27 |
statements: argv.statements |
| 28 |
}, argv['per-file']).catch(suppressEPIPE) |
| 29 |
} |
| 30 |
}) |