Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
output help only when there are no arguments
knex cli should output help only when there are no arguments. current implementation always outputs help, even with correct arguments, such as `knex migrate:status` the argument length should be checked via process.argv. reference: https://github.com/tj/commander.js/#outputhelpcb Add tests for help command
- Loading branch information
1 parent
2e3c7fe
commit 606f944
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const { execCommand } = require('cli-testlab'); | ||
|
||
const cliPkg = require('../../package'); | ||
const KNEX = path.normalize(__dirname + '/../../bin/cli.js'); | ||
|
||
describe('help', () => { | ||
it('Prints help', () => { | ||
return execCommand(`node ${KNEX} --help`, { | ||
expectedOutput: 'Usage', | ||
}); | ||
}); | ||
|
||
it('Prints help using -h flag', () => { | ||
return execCommand(`node ${KNEX} -h`, { | ||
expectedOutput: 'Usage', | ||
}); | ||
}); | ||
|
||
it('Prints help when no arguments are given', () => { | ||
return execCommand(`node ${KNEX}`, { | ||
expectedOutput: 'Usage', | ||
}); | ||
}); | ||
|
||
it('Does not print help when argument is given', () => { | ||
return execCommand(`node ${KNEX} -V`).then(({ stdout, _ }) => { | ||
expect(stdout).to.not.include('Usage'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters