File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -594,9 +594,9 @@ function parse (args, opts) {
594594 function guessType ( key , flags ) {
595595 var type = 'boolean'
596596
597- if ( flags . strings && flags . strings [ key ] ) type = 'string'
598- else if ( flags . numbers && flags . numbers [ key ] ) type = 'number'
599- else if ( flags . arrays && flags . arrays [ key ] ) type = 'array'
597+ if ( checkAllAliases ( key , flags . strings ) ) type = 'string'
598+ else if ( checkAllAliases ( key , flags . numbers ) ) type = 'number'
599+ else if ( checkAllAliases ( key , flags . arrays ) ) type = 'array'
600600
601601 return type
602602 }
Original file line number Diff line number Diff line change @@ -1903,4 +1903,34 @@ describe('yargs-parser', function () {
19031903 } )
19041904 } )
19051905 } )
1906+
1907+ // addresses: https://github.com/yargs/yargs-parser/issues/41
1908+ it ( 'defaults to empty array if array option is provided no values' , function ( ) {
1909+ var parsed = parser ( [ '-f' ] , {
1910+ 'alias' : {
1911+ 'f' : 'files'
1912+ } ,
1913+ 'array' : [ 'files' ]
1914+ } )
1915+ parsed . f . should . deep . equal ( [ ] )
1916+ parsed . files . should . deep . equal ( [ ] )
1917+
1918+ parsed = parser ( [ '--files' ] , {
1919+ 'alias' : {
1920+ 'f' : 'files'
1921+ } ,
1922+ 'array' : [ 'files' ]
1923+ } )
1924+ parsed . f . should . deep . equal ( [ ] )
1925+ parsed . files . should . deep . equal ( [ ] )
1926+
1927+ parsed = parser ( [ '-f' , '-y' ] , {
1928+ 'alias' : {
1929+ 'f' : 'files'
1930+ } ,
1931+ 'array' : [ 'files' ]
1932+ } )
1933+ parsed . f . should . deep . equal ( [ ] )
1934+ parsed . files . should . deep . equal ( [ ] )
1935+ } )
19061936} )
You can’t perform that action at this time.
0 commit comments