Skip to content

Commit 00bbeb2

Browse files
addaleaxbcoe
authored andcommitted
fix(exit code): use test program’s exit code even with --check-coverage
1 parent 1a0ad0b commit 00bbeb2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

bin/nyc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,17 @@ if (argv._[0] === 'report') {
129129
}
130130
sw([wrapper], env)
131131

132+
// Both running the test script invocation and the check-coverage run may
133+
// set process.exitCode. Keep track so that both children are run, but
134+
// a non-zero exit codes in either one leads to an overall non-zero exit code.
135+
process.exitCode = 0
132136
foreground(nyc.mungeArgs(argv), function (done) {
137+
var mainChildExitCode = process.exitCode
138+
133139
if (argv.checkCoverage) {
134140
checkCoverage(argv, function (done) {
141+
process.exitCode = process.exitCode || mainChildExitCode
142+
135143
if (!argv.silent) report(argv)
136144
return done()
137145
})

0 commit comments

Comments
 (0)