@@ -16,7 +16,7 @@ const colorsUtil = require("./colors");
16
16
// S | string array
17
17
18
18
/** Parses the specified command line arguments according to the given configuration. */
19
- function parse ( argv , config , populateDefaults = true ) {
19
+ function parse ( argv , config , propagateDefaults = true ) {
20
20
var options = { } ;
21
21
var unknown = [ ] ;
22
22
var args = [ ] ;
@@ -87,7 +87,7 @@ function parse(argv, config, populateDefaults = true) {
87
87
} else unknown . push ( arg ) ;
88
88
}
89
89
while ( i < k ) trailing . push ( argv [ i ++ ] ) ; // trailing
90
- if ( populateDefaults ) addDefaults ( config , options ) ;
90
+ if ( propagateDefaults ) addDefaults ( config , options ) ;
91
91
92
92
return { options, unknown, arguments : args , trailing } ;
93
93
}
@@ -149,13 +149,9 @@ function merge(config, currentOptions, parentOptions) {
149
149
if ( parentOptions [ key ] != null ) {
150
150
// only parent value present
151
151
if ( Array . isArray ( parentOptions [ key ] ) ) {
152
- if ( mutuallyExclusive ) {
153
- const exclude = currentOptions [ mutuallyExclusive ] ;
154
- if ( exclude ) {
155
- mergedOptions [ key ] = parentOptions [ key ] . filter ( value => ! exclude . includes ( value ) ) ;
156
- } else {
157
- mergedOptions [ key ] = parentOptions [ key ] . slice ( ) ;
158
- }
152
+ let exclude ;
153
+ if ( mutuallyExclusive != null && ( exclude = currentOptions [ mutuallyExclusive ] ) ) {
154
+ mergedOptions [ key ] = parentOptions [ key ] . filter ( value => ! exclude . includes ( value ) ) ;
159
155
} else {
160
156
mergedOptions [ key ] = parentOptions [ key ] . slice ( ) ;
161
157
}
@@ -173,19 +169,12 @@ function merge(config, currentOptions, parentOptions) {
173
169
} else {
174
170
// both current and parent values present
175
171
if ( Array . isArray ( currentOptions [ key ] ) ) {
176
- if ( mutuallyExclusive ) {
177
- const exclude = currentOptions [ mutuallyExclusive ] ;
178
- if ( exclude ) {
179
- mergedOptions [ key ] = [
180
- ...currentOptions [ key ] ,
181
- ...parentOptions [ key ] . filter ( value => ! currentOptions [ key ] . includes ( value ) && ! exclude . includes ( value ) )
182
- ] ;
183
- } else {
184
- mergedOptions [ key ] = [
185
- ...currentOptions [ key ] ,
186
- ...parentOptions [ key ] . filter ( value => ! currentOptions [ key ] . includes ( value ) ) // dedup
187
- ] ;
188
- }
172
+ let exclude ;
173
+ if ( mutuallyExclusive != null && ( exclude = currentOptions [ mutuallyExclusive ] ) ) {
174
+ mergedOptions [ key ] = [
175
+ ...currentOptions [ key ] ,
176
+ ...parentOptions [ key ] . filter ( value => ! currentOptions [ key ] . includes ( value ) && ! exclude . includes ( value ) )
177
+ ] ;
189
178
} else {
190
179
mergedOptions [ key ] = [
191
180
...currentOptions [ key ] ,
0 commit comments