Skip to content

Commit

Permalink
fix: prevent default behavior of arg-parser lib
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Jun 27, 2020
1 parent 60abb0d commit 927bce2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/webpack-cli/lib/utils/arg-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ function argParser(options, args, argsOnly = false, name = '', helpFunction = un
let flagsWithType = option.type !== Boolean ? flags + ' <value>' : flags;
if (option.type === Boolean || option.type === String) {
if (!option.multiple) {
parserInstance.option(flagsWithType, option.description, option.defaultValue);
parserInstance.option(flagsWithType, option.description, option.defaultValue).action(() => {});
} else {
const multiArg = (value, previous = []) => previous.concat([value]);
parserInstance.option(flagsWithType, option.description, multiArg, option.defaultValue);
parserInstance.option(flagsWithType, option.description, multiArg, option.defaultValue).action(() => {});
}
} else if (option.type === Number) {
parserInstance.option(flagsWithType, option.description, Number, option.defaultValue);
} else {
// in this case the type is a parsing function
if (option.type.length > 1) {
flagsWithType = flags + ' [value]';
parserInstance.option(flagsWithType, option.description, option.type[0], option.defaultValue);
parserInstance.option(flagsWithType, option.description, option.type[0], option.defaultValue).action(() => {});
} else {
parserInstance.option(flagsWithType, option.description, option.type, option.defaultValue);
parserInstance.option(flagsWithType, option.description, option.type, option.defaultValue).action(() => {});
}
}

Expand Down

0 comments on commit 927bce2

Please sign in to comment.