Skip to content

Commit

Permalink
fix: [object Object] was accidentally being populated on options obje…
Browse files Browse the repository at this point in the history
…ct (#736)
  • Loading branch information
Janpot authored and bcoe committed Dec 17, 2016
1 parent 27e1a57 commit f755e27
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/yargs.js
Expand Up @@ -64,6 +64,8 @@ describe('yargs dsl tests', function () {
})

r.errors[0].should.match(/really cool key/)
r.result.should.have.property('x')
r.result.should.not.have.property('[object Object]')
})

it('treats usage as alias for options, if object provided as first argument', function () {
Expand Down
8 changes: 7 additions & 1 deletion yargs.js
Expand Up @@ -383,7 +383,13 @@ function Yargs (processArgs, cwd, parentRequire) {
}

self.describe = function (key, desc) {
options.key[key] = true
if (typeof key === 'object') {
Object.keys(key).forEach(function (k) {
options.key[k] = true
})
} else {
options.key[key] = true
}
usage.describe(key, desc)
return self
}
Expand Down

0 comments on commit f755e27

Please sign in to comment.