Skip to content

Commit

Permalink
fix: always invoke instrumenter callback, set appropriate exit-code (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
thegecko authored and bcoe committed Oct 30, 2017
1 parent 7294308 commit 7ea96ba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ NYC.prototype.instrumentAllFiles = function (input, output, cb) {
} catch (err) {
return cb(err)
}
cb()
}

NYC.prototype.walkAllFiles = function (dir, visitor) {
Expand Down
8 changes: 6 additions & 2 deletions lib/commands/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ exports.handler = function (argv) {
})

nyc.instrumentAllFiles(argv.input, argv.output, function (err) {
if (err) console.error(err.message)
process.exit(1)
if (err) {
console.error(err.message)
process.exit(1)
} else {
process.exit(0)
}
})
}
17 changes: 17 additions & 0 deletions test/nyc-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,23 @@ describe('the nyc cli', function () {
done()
})
})

it('allows a sub-directory of files to be instrumented', function (done) {
var args = [bin, 'instrument', './subdir/input-dir', './output']

var proc = spawn(process.execPath, args, {
cwd: fixturesCLI,
env: env
})

proc.on('close', function (code) {
code.should.equal(0)
var files = fs.readdirSync(path.resolve(fixturesCLI, './output'))
files.should.include('index.js')
rimraf.sync(path.resolve(fixturesCLI, 'output'))
done()
})
})
})
})

Expand Down

0 comments on commit 7ea96ba

Please sign in to comment.