Skip to content

Commit a27b694

Browse files
shinnnbcoe
authored andcommitted
fix: exit with code 1 when report output fails (bcoe#92)
1 parent 6b93355 commit a27b694

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

bin/c8.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ async function run () {
2929

3030
process.env.NODE_V8_COVERAGE = argv.tempDirectory
3131
foreground(hideInstrumenterArgs(argv), async (done) => {
32-
await outputReport(argv)
32+
try {
33+
await outputReport(argv)
34+
} catch (err) {
35+
console.error(err.stack)
36+
process.exitCode = 1
37+
}
3338
done()
3439
})
3540
}

test/integration.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ describe('c8', () => {
5353
)
5454
})
5555

56+
it('exits with 1 when report output fails', () => {
57+
const { status, stderr } = spawnSync(nodePath, [
58+
c8Path,
59+
'--clean=false',
60+
'--reporter=unknown',
61+
nodePath,
62+
'--version'
63+
])
64+
status.should.equal(1)
65+
stderr.toString().should.match(/Cannot find module 'unknown'/u)
66+
})
67+
5668
describe('check-coverage', () => {
5769
before(() => {
5870
spawnSync(nodePath, [

0 commit comments

Comments
 (0)