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 pkgConf parsing bug outlined in #37 #45

Merged
merged 1 commit into from
Aug 9, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'])
})
})