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
| var NYC
| try {
| NYC = require('../../index.covered.js')
| } catch (e) {
| NYC = require('../../index.js')
| }
|
| exports.command = 'check-coverage'
|
| exports.describe = 'check whether coverage is within thresholds provided'
|
| exports.builder = function (yargs) {
| yargs
| .option('branches', {
| default: 0,
| description: 'what % of branches must be covered?'
| })
| .option('functions', {
| default: 0,
| description: 'what % of functions must be covered?'
| })
| .option('lines', {
| default: 90,
| description: 'what % of lines must be covered?'
| })
| .option('statements', {
| default: 0,
| description: 'what % of statements must be covered?'
| })
| .option('per-file', {
| default: false,
| description: 'check thresholds per file'
| })
| .example('$0 check-coverage --lines 95', "check whether the JSON in nyc's output folder meets the thresholds provided")
| }
|
| exports.handler = function (argv) {
| process.env.NYC_CWD = process.cwd()
|
| ;(new NYC(argv)).checkCoverage({
| lines: argv.lines,
| functions: argv.functions,
| branches: argv.branches,
| statements: argv.statements
| }, argv['per-file'])
| }
|
|