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:
10331033changes:
10341034 - version: REPLACEME
10351035 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`.
10371037 - version:
10381038 - v18.7.0
10391039 - v16.17.0
Original file line number Diff line number Diff line change @@ -333,15 +333,17 @@ const parseArgs = (config = kEmptyObject) => {
333333
334334 const defaultValue = objectGetOwn ( optionConfig , 'default' ) ;
335335 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 ;
344345 }
346+ validator ( defaultValue , `options.${ longOption } .default` ) ;
345347 }
346348 }
347349 ) ;
You can’t perform that action at this time.
0 commit comments