Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: normalized keys were not enumerable (#247)
  • Loading branch information
bcoe committed Feb 29, 2020
1 parent 485d281 commit 57119f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Expand Up @@ -465,6 +465,7 @@ function parse (args, opts) {
const keys = [key].concat(flags.aliases[key] || [])
keys.forEach(function (key) {
Object.defineProperty(argvReturn, key, {
enumerable: true,
get () {
return val
},
Expand Down
10 changes: 10 additions & 0 deletions test/yargs-parser.js
Expand Up @@ -342,6 +342,16 @@ describe('yargs-parser', function () {
a.should.have.property('s').and.deep.equal(expected)
a.should.have.property('save').and.deep.equal(expected)
})

it('should allow normalized keys to be enumerated', () => {
var a = parser(['-s', ['', 'tmp', '..', ''].join(path.sep)], {
alias: {
s: ['save']
},
normalize: 's'
})
Object.keys(a).should.include('s')
})
})

describe('alias', function () {
Expand Down

0 comments on commit 57119f9

Please sign in to comment.