@@ -18,7 +18,7 @@ test('Everything after a bare `--` is considered a positional argument', functio
1818
1919test ( 'args are true' , function ( t ) {
2020 const passedArgs = [ '--foo' , '--bar' ] ;
21- const expected = { flags : { foo : true , bar : true } , values : { foo : [ undefined ] , bar : [ undefined ] } , positionals : [ ] } ;
21+ const expected = { flags : { foo : true , bar : true } , values : { foo : undefined , bar : undefined } , positionals : [ ] } ;
2222 const args = parseArgs ( passedArgs ) ;
2323
2424 t . deepEqual ( args , expected , 'args are true' ) ;
@@ -28,7 +28,7 @@ test('args are true', function(t) {
2828
2929test ( 'arg is true and positional is identified' , function ( t ) {
3030 const passedArgs = [ '--foo=a' , '--foo' , 'b' ] ;
31- const expected = { flags : { foo : true } , values : { foo : [ undefined ] } , positionals : [ 'b' ] } ;
31+ const expected = { flags : { foo : true } , values : { foo : undefined } , positionals : [ 'b' ] } ;
3232 const args = parseArgs ( passedArgs ) ;
3333
3434 t . deepEqual ( args , expected , 'arg is true and positional is identified' ) ;
@@ -39,7 +39,7 @@ test('arg is true and positional is identified', function(t) {
3939test ( 'args equals are passed "withValue"' , function ( t ) {
4040 const passedArgs = [ '--so=wat' ] ;
4141 const passedOptions = { withValue : [ 'so' ] } ;
42- const expected = { flags : { so : true } , values : { so : [ 'wat' ] } , positionals : [ ] } ;
42+ const expected = { flags : { so : true } , values : { so : 'wat' } , positionals : [ ] } ;
4343 const args = parseArgs ( passedArgs , passedOptions ) ;
4444
4545 t . deepEqual ( args , expected , 'arg value is passed' ) ;
@@ -50,14 +50,25 @@ test('args equals are passed "withValue"', function(t) {
5050test ( 'same arg is passed twice "withValue" and last value is recorded' , function ( t ) {
5151 const passedArgs = [ '--foo=a' , '--foo' , 'b' ] ;
5252 const passedOptions = { withValue : [ 'foo' ] } ;
53- const expected = { flags : { foo : true } , values : { foo : [ 'b' ] } , positionals : [ ] } ;
53+ const expected = { flags : { foo : true } , values : { foo : 'b' } , positionals : [ ] } ;
5454 const args = parseArgs ( passedArgs , passedOptions ) ;
5555
5656 t . deepEqual ( args , expected , 'last arg value is passed' ) ;
5757
5858 t . end ( ) ;
5959} ) ;
6060
61+ test ( 'first arg passed for "withValue" and "multiples" is in array' , function ( t ) {
62+ const passedArgs = [ '--foo=a' ] ;
63+ const passedOptions = { withValue : [ 'foo' ] , multiples : [ 'foo' ] } ;
64+ const expected = { flags : { foo : true } , values : { foo : [ 'a' ] } , positionals : [ ] } ;
65+ const args = parseArgs ( passedArgs , passedOptions ) ;
66+
67+ t . deepEqual ( args , expected , 'first multiple in array' ) ;
68+
69+ t . end ( ) ;
70+ } ) ;
71+
6172test ( 'args are passed "withValue" and "multiples"' , function ( t ) {
6273 const passedArgs = [ '--foo=a' , '--foo' , 'b' ] ;
6374 const passedOptions = { withValue : [ 'foo' ] , multiples : [ 'foo' ] } ;
@@ -77,7 +88,7 @@ test('correct default args when use node -p', function(t) {
7788 const result = parseArgs ( ) ;
7889
7990 const expected = { flags : { foo : true } ,
80- values : { foo : [ undefined ] } ,
91+ values : { foo : undefined } ,
8192 positionals : [ ] } ;
8293 t . deepEqual ( result , expected ) ;
8394
@@ -94,7 +105,7 @@ test('correct default args when use node --print', function(t) {
94105 const result = parseArgs ( ) ;
95106
96107 const expected = { flags : { foo : true } ,
97- values : { foo : [ undefined ] } ,
108+ values : { foo : undefined } ,
98109 positionals : [ ] } ;
99110 t . deepEqual ( result , expected ) ;
100111
@@ -111,7 +122,7 @@ test('correct default args when use node -e', function(t) {
111122 const result = parseArgs ( ) ;
112123
113124 const expected = { flags : { foo : true } ,
114- values : { foo : [ undefined ] } ,
125+ values : { foo : undefined } ,
115126 positionals : [ ] } ;
116127 t . deepEqual ( result , expected ) ;
117128
@@ -128,7 +139,7 @@ test('correct default args when use node --eval', function(t) {
128139 const result = parseArgs ( ) ;
129140
130141 const expected = { flags : { foo : true } ,
131- values : { foo : [ undefined ] } ,
142+ values : { foo : undefined } ,
132143 positionals : [ ] } ;
133144 t . deepEqual ( result , expected ) ;
134145
@@ -145,7 +156,7 @@ test('correct default args when normal arguments', function(t) {
145156 const result = parseArgs ( ) ;
146157
147158 const expected = { flags : { foo : true } ,
148- values : { foo : [ undefined ] } ,
159+ values : { foo : undefined } ,
149160 positionals : [ ] } ;
150161 t . deepEqual ( result , expected ) ;
151162
@@ -160,7 +171,7 @@ test('excess leading dashes on options are retained', function(t) {
160171 const passedOptions = { } ;
161172 const expected = {
162173 flags : { '-triple' : true } ,
163- values : { '-triple' : [ undefined ] } ,
174+ values : { '-triple' : undefined } ,
164175 positionals : [ ]
165176 } ;
166177 const result = parseArgs ( passedArgs , passedOptions ) ;
0 commit comments