113025ee7f974d1336cfd3ac8e5858f15c929fed.svn-base
2.25 KB
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
const testExclude = require('test-exclude')
const NYC = require('../../index.js')
exports.command = 'check-coverage'
exports.describe = 'check whether coverage is within thresholds provided'
exports.builder = function (yargs) {
yargs
.demandCommand(0, 0)
.option('exclude', {
alias: 'x',
default: testExclude.defaultExclude,
describe: 'a list of specific files and directories that should be excluded from coverage, glob patterns are supported, node_modules is always excluded',
global: false
})
.option('exclude-node-modules', {
default: true,
type: 'boolean',
describe: 'whether or not to exclude all node_module folders (i.e. **/node_modules/**) by default',
global: false
})
.option('exclude-after-remap', {
default: true,
type: 'boolean',
description: 'should exclude logic be performed after the source-map remaps filenames?',
global: false
})
.option('include', {
alias: 'n',
default: [],
describe: 'a list of specific files that should be covered, glob patterns are supported',
global: false
})
.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'
})
.option('temp-dir', {
alias: 't',
describe: 'directory to read raw coverage information from',
default: './.nyc_output',
global: false
})
.option('temp-directory', {
hidden: true,
global: false
})
.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'])
}