| 1 |
'use strict' |
| 2 |
|
| 3 |
const NYC = require('../../index.js') |
| 4 |
const { cliWrapper, suppressEPIPE, setupOptions } = require('./helpers.js') |
| 5 |
|
| 6 |
exports.command = 'check-coverage' |
| 7 |
|
| 8 |
exports.describe = 'check whether coverage is within thresholds provided' |
| 9 |
|
| 10 |
exports.builder = function (yargs) { |
| 11 |
yargs |
| 12 |
.demandCommand(0, 0) |
| 13 |
.example('$0 check-coverage --lines 95', "check whether the JSON in nyc's output folder meets the thresholds provided") |
| 14 |
|
| 15 |
setupOptions(yargs, 'check-coverage') |
| 16 |
} |
| 17 |
|
| 18 |
exports.handler = cliWrapper(async argv => { |
| 19 |
process.env.NYC_CWD = process.cwd() |
| 20 |
|
| 21 |
const nyc = new NYC(argv) |
| 22 |
await nyc.checkCoverage({ |
| 23 |
lines: argv.lines, |
| 24 |
functions: argv.functions, |
| 25 |
branches: argv.branches, |
| 26 |
statements: argv.statements |
| 27 |
}, argv['per-file']).catch(suppressEPIPE) |
| 28 |
}) |