cli: exit with error code 1 on invalid command (#461)

This commit is contained in:
Gleb Bahmutov
2017-09-13 12:37:15 -04:00
committed by GitHub
parent ae750c2730
commit 70a7fa0572
4 changed files with 9 additions and 8 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
exports['cli unknown command shows usage and exits 1'] = `
command: bin/cypress foo
code: 0
failed: false
code: 1
failed: true
killed: false
signal: null
timedOut: false
+4 -3
View File
@@ -121,16 +121,17 @@ module.exports = {
debug('cli starts with arguments %j', args)
//# if there are no arguments
// if there are no arguments
if (args.length <= 2) {
//# then display the help
// then display the help
program.help()
// exits
}
const firstCommand = args[2]
if (!_.includes(knownCommands, firstCommand)) {
logger.error('Unknown command', `"${firstCommand}"`)
program.help()
program.outputHelp()
return util.exit(1)
}
+1 -1
View File
@@ -56,7 +56,7 @@
"chai": "^3.5.0",
"clear-module": "^2.1.0",
"dependency-check": "^2.8.0",
"execa-wrap": "1.0.0",
"execa-wrap": "1.1.0",
"nock": "^9.0.9",
"sinon": "3.2.1",
"snap-shot-it": "4.0.0",
+2 -2
View File
@@ -20,11 +20,11 @@ describe('cli', function () {
this.exec = (args) => cli.init(`node test ${args}`.split(' '))
})
context('unknown command', () =>
context('unknown command', () => {
it('shows usage and exits', () =>
execa('bin/cypress', ['foo']).then(snapshot)
)
)
})
context('cypress version', function () {
it('reports package version', function (done) {