Skip to content

Commit

Permalink
fix: respect negatedDescription for flags from schema
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Jan 23, 2022
1 parent 2e3ed44 commit 03ef425
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/webpack-cli/lib/webpack-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ class WebpackCLI {

if (option.configs) {
let needNegativeOption = false;
let negatedDescription;
const mainOptionType = new Set();

option.configs.forEach((config) => {
Expand All @@ -413,6 +414,7 @@ class WebpackCLI {
case "boolean":
if (!needNegativeOption) {
needNegativeOption = true;
negatedDescription = config.negatedDescription;
}

mainOptionType.add(Boolean);
Expand Down Expand Up @@ -454,16 +456,6 @@ class WebpackCLI {
return enumTypes;
}
}

if (needNegativeOption) {
negativeOption = {
flags: `--no-${option.name}`,
description:
config.negatedDescription ||
option.negatedDescription ||
`Negative '${option.name}' option.`,
};
}
});

mainOption = {
Expand All @@ -473,6 +465,14 @@ class WebpackCLI {
multiple: option.multiple,
defaultValue: option.defaultValue,
};

if (needNegativeOption) {
negativeOption = {
flags: `--no-${option.name}`,
description:
negatedDescription || option.negatedDescription || `Negative '${option.name}' option.`,
};
}
} else {
mainOption = {
flags: option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`,
Expand Down

0 comments on commit 03ef425

Please sign in to comment.