File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -351,7 +351,8 @@ function parse (args, opts) {
351351
352352 // Set normalized value when key is in 'normalize' and in 'arrays'
353353 if ( checkAllAliases ( key , flags . normalize ) && checkAllAliases ( key , flags . arrays ) ) {
354- value = path . normalize ( val )
354+ if ( Array . isArray ( val ) ) value = val . map ( path . normalize )
355+ else value = path . normalize ( val )
355356 }
356357
357358 var splitKey = key . split ( '.' )
Original file line number Diff line number Diff line change @@ -2025,4 +2025,14 @@ describe('yargs-parser', function () {
20252025 parsed . error . message . should . equal ( 'banana' )
20262026 } )
20272027 } )
2028+
2029+ // see: https://github.com/yargs/yargs-parser/issues/37
2030+ it ( 'normalizes all paths in array when provided via config object' , function ( ) {
2031+ var argv = parser ( [ '--foo' , 'bar' ] , {
2032+ array : [ 'a' ] ,
2033+ normalize : [ 'a' ] ,
2034+ configObjects : [ { 'a' : [ 'bin/../a.txt' , 'bin/../b.txt' ] } ]
2035+ } )
2036+ argv . a . should . deep . equal ( [ 'a.txt' , 'b.txt' ] )
2037+ } )
20282038} )
You can’t perform that action at this time.
0 commit comments