Skip to content

Commit f755e27

Browse files
Janpotbcoe
authored andcommitted
fix: [object Object] was accidentally being populated on options object (#736)
1 parent 27e1a57 commit f755e27

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

test/yargs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ describe('yargs dsl tests', function () {
6464
})
6565

6666
r.errors[0].should.match(/really cool key/)
67+
r.result.should.have.property('x')
68+
r.result.should.not.have.property('[object Object]')
6769
})
6870

6971
it('treats usage as alias for options, if object provided as first argument', function () {

yargs.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,13 @@ function Yargs (processArgs, cwd, parentRequire) {
383383
}
384384

385385
self.describe = function (key, desc) {
386-
options.key[key] = true
386+
if (typeof key === 'object') {
387+
Object.keys(key).forEach(function (k) {
388+
options.key[k] = true
389+
})
390+
} else {
391+
options.key[key] = true
392+
}
387393
usage.describe(key, desc)
388394
return self
389395
}

0 commit comments

Comments
 (0)