Skip to content

Commit

Permalink
fix: address min/max validation message regression (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Jan 10, 2017
1 parent 8de8272 commit 2e5ce0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions test/validation.js
Expand Up @@ -239,6 +239,17 @@ describe('validation tests', function () {
.argv
})

// address regression in: https://github.com/yargs/yargs/pull/740
it('custom failure message should be printed for both min and max constraints', function (done) {
yargs(['foo'])
.demand(0, 0, 'hey! give me a custom exit message')
.fail(function (msg) {
expect(msg).to.equal('hey! give me a custom exit message')
return done()
})
.argv
})

it('interprets min relative to command', function () {
var failureMsg
yargs('lint')
Expand Down
2 changes: 1 addition & 1 deletion yargs.js
Expand Up @@ -318,7 +318,7 @@ function Yargs (processArgs, cwd, parentRequire) {
}

if (typeof keys === 'number') {
self.demandCommand(keys, max, msg)
self.demandCommand(keys, max, msg, msg)
} else if (Array.isArray(keys)) {
keys.forEach(function (key) {
self.demandOption(key, msg)
Expand Down

0 comments on commit 2e5ce0f

Please sign in to comment.