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: address min/max validation message regression #750

Merged
merged 1 commit into from Jan 10, 2017
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
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