File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
lib/internal/util/parse_args Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -1033,7 +1033,7 @@ added:
1033
1033
changes:
1034
1034
- version: REPLACEME
1035
1035
pr-url: https://github.com/nodejs/node/pull/44631
1036
- description: add support for default values in input `config`.
1036
+ description: Add support for default values in input `config`.
1037
1037
- version:
1038
1038
- v18.7.0
1039
1039
- v16.17.0
Original file line number Diff line number Diff line change @@ -333,15 +333,17 @@ const parseArgs = (config = kEmptyObject) => {
333
333
334
334
const defaultValue = objectGetOwn ( optionConfig , 'default' ) ;
335
335
if ( defaultValue !== undefined ) {
336
- if ( optionType === 'string' && ! multipleOption ) {
337
- validateString ( defaultValue , `options.${ longOption } .default` ) ;
338
- } else if ( optionType === 'string' && multipleOption ) {
339
- validateStringArray ( defaultValue , `options.${ longOption } .default` ) ;
340
- } else if ( optionType === 'boolean' && ! multipleOption ) {
341
- validateBoolean ( defaultValue , `options.${ longOption } .default` ) ;
342
- } else if ( optionType === 'boolean' && multipleOption ) {
343
- validateBooleanArray ( defaultValue , `options.${ longOption } .default` ) ;
336
+ let validator ;
337
+ switch ( optionType ) {
338
+ case 'string' :
339
+ validator = multipleOption ? validateStringArray : validateString ;
340
+ break ;
341
+
342
+ case 'boolean' :
343
+ validator = multipleOption ? validateBooleanArray : validateBoolean ;
344
+ break ;
344
345
}
346
+ validator ( defaultValue , `options.${ longOption } .default` ) ;
345
347
}
346
348
}
347
349
) ;
You can’t perform that action at this time.
0 commit comments