Skip to content

Commit 7ea96ba

Browse files
thegeckobcoe
authored andcommitted
fix: always invoke instrumenter callback, set appropriate exit-code (#703)
1 parent 7294308 commit 7ea96ba

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ NYC.prototype.instrumentAllFiles = function (input, output, cb) {
231231
} catch (err) {
232232
return cb(err)
233233
}
234+
cb()
234235
}
235236

236237
NYC.prototype.walkAllFiles = function (dir, visitor) {

lib/commands/instrument.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ exports.handler = function (argv) {
5454
})
5555

5656
nyc.instrumentAllFiles(argv.input, argv.output, function (err) {
57-
if (err) console.error(err.message)
58-
process.exit(1)
57+
if (err) {
58+
console.error(err.message)
59+
process.exit(1)
60+
} else {
61+
process.exit(0)
62+
}
5963
})
6064
}

test/nyc-bin.js

+17
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,23 @@ describe('the nyc cli', function () {
479479
done()
480480
})
481481
})
482+
483+
it('allows a sub-directory of files to be instrumented', function (done) {
484+
var args = [bin, 'instrument', './subdir/input-dir', './output']
485+
486+
var proc = spawn(process.execPath, args, {
487+
cwd: fixturesCLI,
488+
env: env
489+
})
490+
491+
proc.on('close', function (code) {
492+
code.should.equal(0)
493+
var files = fs.readdirSync(path.resolve(fixturesCLI, './output'))
494+
files.should.include('index.js')
495+
rimraf.sync(path.resolve(fixturesCLI, 'output'))
496+
done()
497+
})
498+
})
482499
})
483500
})
484501

0 commit comments

Comments
 (0)