Skip to content

Commit

Permalink
fix: exit with code 1 when report output fails (bcoe#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinnn authored and bcoe committed May 4, 2019
1 parent 486e090 commit 9d319cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/c8.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ async function run () {

process.env.NODE_V8_COVERAGE = argv.tempDirectory
foreground(hideInstrumenterArgs(argv), async (done) => {
await outputReport(argv)
try {
await outputReport(argv)
} catch (err) {
console.error(err.stack)
process.exitCode = 1
}
done()
})
}
Expand Down
12 changes: 12 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ describe('c8', () => {
)
})

it('exits with 1 when report output fails', () => {
const { status, stderr } = spawnSync(nodePath, [
c8Path,
'--clean=false',
'--reporter=unknown',
nodePath,
'--version'
])
status.should.equal(1)
stderr.toString().should.match(/Cannot find module 'unknown'/u)
})

describe('check-coverage', () => {
before(() => {
spawnSync(nodePath, [
Expand Down

0 comments on commit 9d319cd

Please sign in to comment.