@@ -94,7 +94,11 @@ describe('yargs-parser', function () {
94
94
'--key' , 'value' ,
95
95
'-b' , '--bool' , '--no-meep' , '--multi=baz' ,
96
96
'--' , '--not-a-flag' , '-' , '-h' , '-multi' , '--' , 'eek'
97
- ] )
97
+ ] , {
98
+ configuration : {
99
+ 'populate--' : false
100
+ }
101
+ } )
98
102
parse . should . have . property ( 'c' , true )
99
103
parse . should . have . property ( 'a' , true )
100
104
parse . should . have . property ( 't' , true )
@@ -1260,46 +1264,6 @@ describe('yargs-parser', function () {
1260
1264
} )
1261
1265
} )
1262
1266
1263
- describe ( 'option --' , function ( ) {
1264
- describe ( 'when it is not defined' , function ( ) {
1265
- it ( 'should not initialize the \'--\' array' , function ( ) {
1266
- var result = parser ( [
1267
- 'bare' ,
1268
- '--' , '-h' , 'eek' , '--'
1269
- ] )
1270
- result . should . have . property ( '_' ) . and . deep . equal ( [ 'bare' , '-h' , 'eek' , '--' ] )
1271
- result . should . not . have . property ( '--' )
1272
- } )
1273
- } )
1274
-
1275
- describe ( 'when it is defined' , function ( ) {
1276
- it ( 'should set bare flags to \'_\' array and non-flags to \'--\' array' , function ( ) {
1277
- var result = parser ( [
1278
- '--name=meowmers' , 'bare' , '-cats' , 'woo' , 'moxy' ,
1279
- '-h' , 'awesome' , '--multi=quux' ,
1280
- '--key' , 'value' ,
1281
- '-b' , '--bool' , '--no-meep' , '--multi=baz' ,
1282
- '--' , '--not-a-flag' , '-' , '-h' , '-multi' , '--' , 'eek'
1283
- ] , {
1284
- '--' : true
1285
- } )
1286
- result . should . have . property ( 'c' , true )
1287
- result . should . have . property ( 'a' , true )
1288
- result . should . have . property ( 't' , true )
1289
- result . should . have . property ( 's' , 'woo' )
1290
- result . should . have . property ( 'h' , 'awesome' )
1291
- result . should . have . property ( 'b' , true )
1292
- result . should . have . property ( 'bool' , true )
1293
- result . should . have . property ( 'key' , 'value' )
1294
- result . should . have . property ( 'multi' ) . and . deep . equal ( [ 'quux' , 'baz' ] )
1295
- result . should . have . property ( 'meep' , false )
1296
- result . should . have . property ( 'name' , 'meowmers' )
1297
- result . should . have . property ( '_' ) . and . deep . equal ( [ 'bare' , 'moxy' ] )
1298
- result . should . have . property ( '--' ) . and . deep . equal ( [ '--not-a-flag' , '-' , '-h' , '-multi' , '--' , 'eek' ] )
1299
- } )
1300
- } )
1301
- } )
1302
-
1303
1267
describe ( 'count' , function ( ) {
1304
1268
it ( 'should count the number of times a boolean is present' , function ( ) {
1305
1269
var parsed
@@ -2244,6 +2208,42 @@ describe('yargs-parser', function () {
2244
2208
} )
2245
2209
} )
2246
2210
} )
2211
+
2212
+ describe ( 'populate--' , function ( ) {
2213
+ it ( 'should populate "_" if "populate-- false' , function ( ) {
2214
+ var result = parser ( [
2215
+ 'bare' ,
2216
+ '--' , '-h' , 'eek' , '--'
2217
+ ] , {
2218
+ configuration : { 'populate--' : false }
2219
+ } )
2220
+ result . should . have . property ( '_' ) . and . deep . equal ( [ 'bare' , '-h' , 'eek' , '--' ] )
2221
+ result . should . not . have . property ( '--' )
2222
+ } )
2223
+
2224
+ it ( 'should populate the "--" array by default' , function ( ) {
2225
+ var result = parser ( [
2226
+ '--name=meowmers' , 'bare' , '-cats' , 'woo' , 'moxy' ,
2227
+ '-h' , 'awesome' , '--multi=quux' ,
2228
+ '--key' , 'value' ,
2229
+ '-b' , '--bool' , '--no-meep' , '--multi=baz' ,
2230
+ '--' , '--not-a-flag' , '-' , '-h' , '-multi' , '--' , 'eek'
2231
+ ] )
2232
+ result . should . have . property ( 'c' , true )
2233
+ result . should . have . property ( 'a' , true )
2234
+ result . should . have . property ( 't' , true )
2235
+ result . should . have . property ( 's' , 'woo' )
2236
+ result . should . have . property ( 'h' , 'awesome' )
2237
+ result . should . have . property ( 'b' , true )
2238
+ result . should . have . property ( 'bool' , true )
2239
+ result . should . have . property ( 'key' , 'value' )
2240
+ result . should . have . property ( 'multi' ) . and . deep . equal ( [ 'quux' , 'baz' ] )
2241
+ result . should . have . property ( 'meep' , false )
2242
+ result . should . have . property ( 'name' , 'meowmers' )
2243
+ result . should . have . property ( '_' ) . and . deep . equal ( [ 'bare' , 'moxy' ] )
2244
+ result . should . have . property ( '--' ) . and . deep . equal ( [ '--not-a-flag' , '-' , '-h' , '-multi' , '--' , 'eek' ] )
2245
+ } )
2246
+ } )
2247
2247
} )
2248
2248
2249
2249
// addresses: https://github.com/yargs/yargs-parser/issues/41
0 commit comments