Skip to content

Commit

Permalink
fix: address pkgConf parsing bug outlined in #37 (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored Aug 9, 2016
1 parent 487fecf commit be76ee6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ function parse (args, opts) {

// Set normalized value when key is in 'normalize' and in 'arrays'
if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
value = path.normalize(val)
if (Array.isArray(val)) value = val.map(path.normalize)
else value = path.normalize(val)
}

var splitKey = key.split('.')
Expand Down
10 changes: 10 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2025,4 +2025,14 @@ describe('yargs-parser', function () {
parsed.error.message.should.equal('banana')
})
})

// see: https://github.com/yargs/yargs-parser/issues/37
it('normalizes all paths in array when provided via config object', function () {
var argv = parser([ '--foo', 'bar' ], {
array: ['a'],
normalize: ['a'],
configObjects: [{'a': ['bin/../a.txt', 'bin/../b.txt']}]
})
argv.a.should.deep.equal(['a.txt', 'b.txt'])
})
})

0 comments on commit be76ee6

Please sign in to comment.