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

fix: Exit with code 1 when nyc doesn't know what to do. #1070

Merged
merged 1 commit into from Apr 17, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/nyc.js
Expand Up @@ -85,5 +85,6 @@ if ([
})
} else {
// I don't have a clue what you're doing.
process.exitCode = 1
yargs.showHelp()
}
19 changes: 18 additions & 1 deletion test/nyc-integration.js
Expand Up @@ -12,7 +12,7 @@ const glob = require('glob')
const isWindows = require('is-windows')()
const rimraf = require('rimraf')
const makeDir = require('make-dir')
const spawn = require('child_process').spawn
const { spawn, spawnSync } = require('child_process')
const si = require('strip-indent')

require('chai').should()
Expand Down Expand Up @@ -1079,6 +1079,23 @@ describe('the nyc cli', function () {
})
})

it('help shows to stderr when main command doesn\'t know what to do', () => {
const opts = {
cwd: fixturesCLI,
env,
encoding: 'utf8'
}

const help = spawnSync(process.execPath, [bin, '--help'], opts)
const unknown = spawnSync(process.execPath, [bin], opts)
help.status.should.equal(0)
unknown.status.should.equal(1)
help.stderr.should.equal('')
unknown.stdout.should.equal('')
help.stdout.should.not.equal('')
help.stdout.should.equal(unknown.stderr)
})

describe('args', function () {
it('does not interpret args intended for instrumented bin', function (done) {
var args = [bin, '--silent', process.execPath, 'args.js', '--help', '--version']
Expand Down