Skip to content

Commit b909575

Browse files
authored
fix: Use a single instance of nyc for all actions of main command. (#1059)
This shares the same instance of nyc for execution, checking coverage and reporting.
1 parent 997ed29 commit b909575

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

bin/nyc.js

+12-24
Original file line numberDiff line numberDiff line change
@@ -66,34 +66,22 @@ if ([
6666
var mainChildExitCode = process.exitCode
6767

6868
if (argv.checkCoverage) {
69-
checkCoverage(argv)
69+
nyc.checkCoverage({
70+
lines: argv.lines,
71+
functions: argv.functions,
72+
branches: argv.branches,
73+
statements: argv.statements
74+
}, argv['per-file'])
7075
process.exitCode = process.exitCode || mainChildExitCode
71-
if (!argv.silent) report(argv)
72-
return done()
73-
} else {
74-
if (!argv.silent) report(argv)
75-
return done()
7676
}
77+
78+
if (!argv.silent) {
79+
nyc.report()
80+
}
81+
82+
return done()
7783
})
7884
} else {
7985
// I don't have a clue what you're doing.
8086
yargs.showHelp()
8187
}
82-
83-
function report (argv) {
84-
process.env.NYC_CWD = process.cwd()
85-
86-
var nyc = new NYC(argv)
87-
nyc.report()
88-
}
89-
90-
function checkCoverage (argv, cb) {
91-
process.env.NYC_CWD = process.cwd()
92-
93-
;(new NYC(argv)).checkCoverage({
94-
lines: argv.lines,
95-
functions: argv.functions,
96-
branches: argv.branches,
97-
statements: argv.statements
98-
}, argv['per-file'])
99-
}

0 commit comments

Comments
 (0)