Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumenter test and callback #703

Merged
merged 2 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome \o/ thank you for the test. random aside, I think these integration tests are probably the approach I should have taken all along with nyc, I think I might start retiring some of the older crufty test files that are kicking around.

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