Skip to content

Commit

Permalink
Set exitCode correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
nwalters512 committed Apr 19, 2024
1 parent 825bdbc commit 62735fe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/nyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function main () {
// a non-zero exit codes in either one leads to an overall non-zero exit code.
process.exitCode = 0
foregroundChild(childArgs, async () => {
const mainChildExitCode = process.exitCode
let exitCode = process.exitCode

try {
await nyc.writeProcessIndex()
Expand All @@ -100,18 +100,20 @@ async function main () {
branches: argv.branches,
statements: argv.statements
}, argv['per-file']).catch(suppressEPIPE)
process.exitCode = process.exitCode || mainChildExitCode
exitCode = process.exitCode || exitCode
}

if (!argv.silent) {
await nyc.report().catch(suppressEPIPE)
}
} catch (error) {
/* istanbul ignore next */
process.exitCode = process.exitCode || mainChildExitCode || 1
exitCode = process.exitCode || exitCode || 1
/* istanbul ignore next */
console.error(error.message)
}

return exitCode
})
}

Expand Down

0 comments on commit 62735fe

Please sign in to comment.