Skip to content

Commit

Permalink
refactor: code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Mar 25, 2021
1 parent 314abb0 commit 0c7601f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion OPTIONS.md
Expand Up @@ -858,7 +858,7 @@ Commands:
configtest|t [config-path] Validate a webpack configuration.
help|h [command] [option] Display help for commands and options.
info|i [options] Outputs information about your system.
init|c [generation-path] [options] Initialize a new webpack project.
init|c [generation-path] [options] Initialize a new webpack configuration.
loader|l [output-path] Scaffold a loader.
migrate|m <config-path> [new-config-path] Migrate a configuration to a new version.
plugin|p [output-path] Scaffold a plugin.
Expand Down
29 changes: 11 additions & 18 deletions packages/webpack-cli/lib/webpack-cli.js
Expand Up @@ -122,11 +122,6 @@ class WebpackCLI {
if (option.configs) {
let needNegativeOption = false;
let mainOptionType = new Set();
let isBuiltInFlag = false;

if (this.builtInFlags) {
isBuiltInFlag = this.builtInFlags.map(({ name }) => name).includes(option.name);
}

option.configs.forEach((config) => {
// Possible value: "enum" | "string" | "path" | "number" | "boolean" | "RegExp" | "reset"
Expand All @@ -135,14 +130,8 @@ class WebpackCLI {
mainOptionType.add(Boolean);
break;
case 'boolean':
if (isBuiltInFlag) {
if (option.negative) {
needNegativeOption = true;
}
} else {
if (!needNegativeOption) {
needNegativeOption = true;
}
if (!needNegativeOption) {
needNegativeOption = true;
}

mainOptionType.add(Boolean);
Expand Down Expand Up @@ -374,7 +363,8 @@ class WebpackCLI {
alias: 'm',
configs: [
{
type: 'boolean',
type: 'enum',
values: [true],
},
],
description: "Merge two or more configurations using 'webpack-merge'.",
Expand Down Expand Up @@ -441,7 +431,8 @@ class WebpackCLI {
name: 'analyze',
configs: [
{
type: 'boolean',
type: 'enum',
values: [true],
},
],
multiple: false,
Expand All @@ -454,7 +445,8 @@ class WebpackCLI {
type: 'string',
},
{
type: 'boolean',
type: 'enum',
values: [true],
},
],
description: 'Print compilation progress during build.',
Expand All @@ -477,7 +469,8 @@ class WebpackCLI {
type: 'string',
},
{
type: 'boolean',
type: 'enum',
values: [true],
},
],
alias: 'j',
Expand Down Expand Up @@ -609,7 +602,7 @@ class WebpackCLI {
});

this.builtInOptionsCache = options;
this.builtInFlags = builtInFlags;

return options;
}

Expand Down

0 comments on commit 0c7601f

Please sign in to comment.