mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-20 14:11:12 -05:00
cli: exit with error code 1 on invalid command (#461)
This commit is contained in:
@@ -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
@@ -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
@@ -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",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user