Skip to content

Commit 0c7601f

Browse files
refactor: code
1 parent 314abb0 commit 0c7601f

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

OPTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ Commands:
858858
configtest|t [config-path] Validate a webpack configuration.
859859
help|h [command] [option] Display help for commands and options.
860860
info|i [options] Outputs information about your system.
861-
init|c [generation-path] [options] Initialize a new webpack project.
861+
init|c [generation-path] [options] Initialize a new webpack configuration.
862862
loader|l [output-path] Scaffold a loader.
863863
migrate|m <config-path> [new-config-path] Migrate a configuration to a new version.
864864
plugin|p [output-path] Scaffold a plugin.

packages/webpack-cli/lib/webpack-cli.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ class WebpackCLI {
122122
if (option.configs) {
123123
let needNegativeOption = false;
124124
let mainOptionType = new Set();
125-
let isBuiltInFlag = false;
126-
127-
if (this.builtInFlags) {
128-
isBuiltInFlag = this.builtInFlags.map(({ name }) => name).includes(option.name);
129-
}
130125

131126
option.configs.forEach((config) => {
132127
// Possible value: "enum" | "string" | "path" | "number" | "boolean" | "RegExp" | "reset"
@@ -135,14 +130,8 @@ class WebpackCLI {
135130
mainOptionType.add(Boolean);
136131
break;
137132
case 'boolean':
138-
if (isBuiltInFlag) {
139-
if (option.negative) {
140-
needNegativeOption = true;
141-
}
142-
} else {
143-
if (!needNegativeOption) {
144-
needNegativeOption = true;
145-
}
133+
if (!needNegativeOption) {
134+
needNegativeOption = true;
146135
}
147136

148137
mainOptionType.add(Boolean);
@@ -374,7 +363,8 @@ class WebpackCLI {
374363
alias: 'm',
375364
configs: [
376365
{
377-
type: 'boolean',
366+
type: 'enum',
367+
values: [true],
378368
},
379369
],
380370
description: "Merge two or more configurations using 'webpack-merge'.",
@@ -441,7 +431,8 @@ class WebpackCLI {
441431
name: 'analyze',
442432
configs: [
443433
{
444-
type: 'boolean',
434+
type: 'enum',
435+
values: [true],
445436
},
446437
],
447438
multiple: false,
@@ -454,7 +445,8 @@ class WebpackCLI {
454445
type: 'string',
455446
},
456447
{
457-
type: 'boolean',
448+
type: 'enum',
449+
values: [true],
458450
},
459451
],
460452
description: 'Print compilation progress during build.',
@@ -477,7 +469,8 @@ class WebpackCLI {
477469
type: 'string',
478470
},
479471
{
480-
type: 'boolean',
472+
type: 'enum',
473+
values: [true],
481474
},
482475
],
483476
alias: 'j',
@@ -609,7 +602,7 @@ class WebpackCLI {
609602
});
610603

611604
this.builtInOptionsCache = options;
612-
this.builtInFlags = builtInFlags;
605+
613606
return options;
614607
}
615608

0 commit comments

Comments
 (0)