From ee662c4e03cd04559e464edf6f7afc28e988459a Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 5 Jul 2021 17:19:03 +0530 Subject: [PATCH 1/6] feat: show possible values for option in help output --- packages/webpack-cli/lib/webpack-cli.js | 13 ++++++++++++- .../help.test.js.snap.devServer3.webpack5 | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 5ab16847c01..3f731241d76 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1363,10 +1363,21 @@ class WebpackCLI { ); } + const flag = this.getBuiltInOptions().find( + (flag) => option.long === `--${flag.name}`, + ); + + if (flag && flag.configs[0].values) { + this.logger.raw( + `${bold("Possible values:")} ${JSON.stringify( + flag.configs[0].values.join(" | "), + )}`, + ); + } + this.logger.raw(""); // TODO implement this after refactor cli arguments - // logger.raw('Possible values: foo | bar'); // logger.raw('Documentation: https://webpack.js.org/option/name/'); } else { outputIncorrectUsageOfHelp(); diff --git a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack5 b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack5 index e64ba7ddde2..5d31da54734 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack5 +++ b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack5 @@ -2560,6 +2560,7 @@ exports[`help should show help information using the "help --mode" option: stder exports[`help should show help information using the "help --mode" option: stdout 1`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2571,6 +2572,7 @@ Made with ♥ by the webpack team." exports[`help should show help information using the "help --mode" option: stdout 2`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2610,6 +2612,7 @@ exports[`help should show help information using the "help --stats" option: stde exports[`help should show help information using the "help --stats" option: stdout 1`] = ` "Usage: webpack --stats [value] Description: It instructs webpack on how to treat the stats e.g. verbose. +Possible values: \\"none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2678,6 +2681,7 @@ exports[`help should show help information using the "help serve --mode" option: exports[`help should show help information using the "help serve --mode" option: stdout 1`] = ` "Usage: webpack serve --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. From a65444c2680a3af1ddf65939c2060ce81c49a903 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 7 Jul 2021 07:31:31 +0530 Subject: [PATCH 2/6] fix: show all possible values --- packages/webpack-cli/lib/webpack-cli.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 3f731241d76..1068383cbdb 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1367,11 +1367,17 @@ class WebpackCLI { (flag) => option.long === `--${flag.name}`, ); - if (flag && flag.configs[0].values) { + const possibleValues = flag.configs.reduce((accumulator, currentValue) => { + if (currentValue.values) { + return accumulator.concat(currentValue.values); + } else { + return accumulator; + } + }, []); + + if (possibleValues.length > 0) { this.logger.raw( - `${bold("Possible values:")} ${JSON.stringify( - flag.configs[0].values.join(" | "), - )}`, + `${bold("Possible values:")} ${JSON.stringify(possibleValues.join(" | "))}`, ); } From 1160fb8f508a60c548f8762b4268ccb2e106807e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 7 Jul 2021 09:51:07 +0530 Subject: [PATCH 3/6] test: updates --- packages/webpack-cli/lib/webpack-cli.js | 26 +++++++++++-------- .../help.test.js.snap.devServer3.webpack4 | 14 ++++++++++ .../help.test.js.snap.devServer3.webpack5 | 15 +++++++++++ .../help.test.js.snap.devServer4.webpack4 | 14 ++++++++++ .../help.test.js.snap.devServer4.webpack5 | 14 ++++++++++ test/help/help.test.js | 8 ++++++ 6 files changed, 80 insertions(+), 11 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 1068383cbdb..e8f7b0a3146 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1367,18 +1367,22 @@ class WebpackCLI { (flag) => option.long === `--${flag.name}`, ); - const possibleValues = flag.configs.reduce((accumulator, currentValue) => { - if (currentValue.values) { - return accumulator.concat(currentValue.values); - } else { - return accumulator; - } - }, []); + if (flag && flag.configs) { + const possibleValues = flag.configs.reduce((accumulator, currentValue) => { + if (currentValue.values) { + return accumulator.concat(currentValue.values); + } else { + return accumulator; + } + }, []); - if (possibleValues.length > 0) { - this.logger.raw( - `${bold("Possible values:")} ${JSON.stringify(possibleValues.join(" | "))}`, - ); + if (possibleValues.length > 0) { + this.logger.raw( + `${bold("Possible values:")} ${JSON.stringify( + possibleValues.join(" | "), + )}`, + ); + } } this.logger.raw(""); diff --git a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 index 5e9c6cb436b..8603bce8cd4 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 @@ -2515,6 +2515,20 @@ CLI documentation: https://webpack.js.org/api/cli/. Made with ♥ by the webpack team." `; +exports[`help should show help information using the "help --cache-type" option: stderr 1`] = `""`; + +exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` +"Usage: webpack --cache-type +Description: In memory caching. Filesystem caching. +Possible values: \\"memory | filesystem\\" + +To see list of all supported commands and options run 'webpack --help=verbose'. + +Webpack documentation: https://webpack.js.org/. +CLI documentation: https://webpack.js.org/api/cli/. +Made with ♥ by the webpack team." +`; + exports[`help should show help information using the "help --color" option: stderr 1`] = `""`; exports[`help should show help information using the "help --color" option: stdout 1`] = ` diff --git a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack5 b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack5 index 5d31da54734..849523f1832 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack5 +++ b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack5 @@ -2540,6 +2540,20 @@ CLI documentation: https://webpack.js.org/api/cli/. Made with ♥ by the webpack team." `; +exports[`help should show help information using the "help --cache-type" option: stderr 1`] = `""`; + +exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` +"Usage: webpack --cache-type +Description: In memory caching. Filesystem caching. +Possible values: \\"memory | filesystem\\" + +To see list of all supported commands and options run 'webpack --help=verbose'. + +Webpack documentation: https://webpack.js.org/. +CLI documentation: https://webpack.js.org/api/cli/. +Made with ♥ by the webpack team." +`; + exports[`help should show help information using the "help --color" option: stderr 1`] = `""`; exports[`help should show help information using the "help --color" option: stdout 1`] = ` @@ -2627,6 +2641,7 @@ exports[`help should show help information using the "help --target" option: std "Usage: webpack --target Short: webpack -t Description: Sets the build target e.g. node. +Possible values: \\"false\\" To see list of all supported commands and options run 'webpack --help=verbose'. diff --git a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 index 170369e3ff3..a3ce06602ab 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 @@ -2645,6 +2645,20 @@ CLI documentation: https://webpack.js.org/api/cli/. Made with ♥ by the webpack team." `; +exports[`help should show help information using the "help --cache-type" option: stderr 1`] = `""`; + +exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` +"Usage: webpack --cache-type +Description: In memory caching. Filesystem caching. +Possible values: \\"memory | filesystem\\" + +To see list of all supported commands and options run 'webpack --help=verbose'. + +Webpack documentation: https://webpack.js.org/. +CLI documentation: https://webpack.js.org/api/cli/. +Made with ♥ by the webpack team." +`; + exports[`help should show help information using the "help --color" option: stderr 1`] = `""`; exports[`help should show help information using the "help --color" option: stdout 1`] = ` diff --git a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 index 3fa2c24e7bb..68c0d2d2e96 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 +++ b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 @@ -2670,6 +2670,20 @@ CLI documentation: https://webpack.js.org/api/cli/. Made with ♥ by the webpack team." `; +exports[`help should show help information using the "help --cache-type" option: stderr 1`] = `""`; + +exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` +"Usage: webpack --cache-type +Description: In memory caching. Filesystem caching. +Possible values: \\"memory | filesystem\\" + +To see list of all supported commands and options run 'webpack --help=verbose'. + +Webpack documentation: https://webpack.js.org/. +CLI documentation: https://webpack.js.org/api/cli/. +Made with ♥ by the webpack team." +`; + exports[`help should show help information using the "help --color" option: stderr 1`] = `""`; exports[`help should show help information using the "help --color" option: stdout 1`] = ` diff --git a/test/help/help.test.js b/test/help/help.test.js index 627a1ab9929..d7ef6cda29c 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -242,6 +242,14 @@ describe("help", () => { expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); }); + it('should show help information using the "help --cache-type" option', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--cache-type"]); + + expect(exitCode).toBe(0); + expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); + expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); + }); + it('should show help information using the "help --no-stats" option', async () => { const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--no-stats"]); From fa823dc3f01a41c4efef2e70b6016cd07868a984 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 7 Jul 2021 09:55:17 +0530 Subject: [PATCH 4/6] test: update snaps --- .../help/__snapshots__/help.test.js.snap.devServer3.webpack4 | 5 +++++ .../help/__snapshots__/help.test.js.snap.devServer4.webpack4 | 5 +++++ .../help/__snapshots__/help.test.js.snap.devServer4.webpack5 | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 index 8603bce8cd4..c91fdee357a 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 @@ -2549,6 +2549,7 @@ exports[`help should show help information using the "help --mode" option: stder exports[`help should show help information using the "help --mode" option: stdout 1`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2560,6 +2561,7 @@ Made with ♥ by the webpack team." exports[`help should show help information using the "help --mode" option: stdout 2`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2599,6 +2601,7 @@ exports[`help should show help information using the "help --stats" option: stde exports[`help should show help information using the "help --stats" option: stdout 1`] = ` "Usage: webpack --stats [value] Description: It instructs webpack on how to treat the stats e.g. verbose. +Possible values: \\"none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2613,6 +2616,7 @@ exports[`help should show help information using the "help --target" option: std "Usage: webpack --target Short: webpack -t Description: Sets the build target e.g. node. +Possible values: \\"false\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2667,6 +2671,7 @@ exports[`help should show help information using the "help serve --mode" option: exports[`help should show help information using the "help serve --mode" option: stdout 1`] = ` "Usage: webpack serve --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. diff --git a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 index a3ce06602ab..70ea5e297cd 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 @@ -2679,6 +2679,7 @@ exports[`help should show help information using the "help --mode" option: stder exports[`help should show help information using the "help --mode" option: stdout 1`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2690,6 +2691,7 @@ Made with ♥ by the webpack team." exports[`help should show help information using the "help --mode" option: stdout 2`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2729,6 +2731,7 @@ exports[`help should show help information using the "help --stats" option: stde exports[`help should show help information using the "help --stats" option: stdout 1`] = ` "Usage: webpack --stats [value] Description: It instructs webpack on how to treat the stats e.g. verbose. +Possible values: \\"none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2743,6 +2746,7 @@ exports[`help should show help information using the "help --target" option: std "Usage: webpack --target Short: webpack -t Description: Sets the build target e.g. node. +Possible values: \\"false\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2797,6 +2801,7 @@ exports[`help should show help information using the "help serve --mode" option: exports[`help should show help information using the "help serve --mode" option: stdout 1`] = ` "Usage: webpack serve --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. diff --git a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 index 68c0d2d2e96..e76d76b08b9 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 +++ b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 @@ -2704,6 +2704,7 @@ exports[`help should show help information using the "help --mode" option: stder exports[`help should show help information using the "help --mode" option: stdout 1`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2715,6 +2716,7 @@ Made with ♥ by the webpack team." exports[`help should show help information using the "help --mode" option: stdout 2`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2754,6 +2756,7 @@ exports[`help should show help information using the "help --stats" option: stde exports[`help should show help information using the "help --stats" option: stdout 1`] = ` "Usage: webpack --stats [value] Description: It instructs webpack on how to treat the stats e.g. verbose. +Possible values: \\"none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2768,6 +2771,7 @@ exports[`help should show help information using the "help --target" option: std "Usage: webpack --target Short: webpack -t Description: Sets the build target e.g. node. +Possible values: \\"false\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2822,6 +2826,7 @@ exports[`help should show help information using the "help serve --mode" option: exports[`help should show help information using the "help serve --mode" option: stdout 1`] = ` "Usage: webpack serve --mode Description: Defines the mode to pass to webpack. +Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. From 01bb7d9b022d03c3affa2cb4efb2bc85571cd5b7 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 7 Jul 2021 10:55:27 +0530 Subject: [PATCH 5/6] test: fix --- .../__snapshots__/help.test.js.snap.devServer3.webpack4 | 6 ------ .../__snapshots__/help.test.js.snap.devServer4.webpack4 | 6 ------ 2 files changed, 12 deletions(-) diff --git a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 index c91fdee357a..893a4280c37 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 @@ -2520,7 +2520,6 @@ exports[`help should show help information using the "help --cache-type" option: exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` "Usage: webpack --cache-type Description: In memory caching. Filesystem caching. -Possible values: \\"memory | filesystem\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2549,7 +2548,6 @@ exports[`help should show help information using the "help --mode" option: stder exports[`help should show help information using the "help --mode" option: stdout 1`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. -Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2561,7 +2559,6 @@ Made with ♥ by the webpack team." exports[`help should show help information using the "help --mode" option: stdout 2`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. -Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2601,7 +2598,6 @@ exports[`help should show help information using the "help --stats" option: stde exports[`help should show help information using the "help --stats" option: stdout 1`] = ` "Usage: webpack --stats [value] Description: It instructs webpack on how to treat the stats e.g. verbose. -Possible values: \\"none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2616,7 +2612,6 @@ exports[`help should show help information using the "help --target" option: std "Usage: webpack --target Short: webpack -t Description: Sets the build target e.g. node. -Possible values: \\"false\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2671,7 +2666,6 @@ exports[`help should show help information using the "help serve --mode" option: exports[`help should show help information using the "help serve --mode" option: stdout 1`] = ` "Usage: webpack serve --mode Description: Defines the mode to pass to webpack. -Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. diff --git a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 index 70ea5e297cd..ca32b7ec7c2 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 @@ -2650,7 +2650,6 @@ exports[`help should show help information using the "help --cache-type" option: exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` "Usage: webpack --cache-type Description: In memory caching. Filesystem caching. -Possible values: \\"memory | filesystem\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2679,7 +2678,6 @@ exports[`help should show help information using the "help --mode" option: stder exports[`help should show help information using the "help --mode" option: stdout 1`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. -Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2691,7 +2689,6 @@ Made with ♥ by the webpack team." exports[`help should show help information using the "help --mode" option: stdout 2`] = ` "Usage: webpack --mode Description: Defines the mode to pass to webpack. -Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2731,7 +2728,6 @@ exports[`help should show help information using the "help --stats" option: stde exports[`help should show help information using the "help --stats" option: stdout 1`] = ` "Usage: webpack --stats [value] Description: It instructs webpack on how to treat the stats e.g. verbose. -Possible values: \\"none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2746,7 +2742,6 @@ exports[`help should show help information using the "help --target" option: std "Usage: webpack --target Short: webpack -t Description: Sets the build target e.g. node. -Possible values: \\"false\\" To see list of all supported commands and options run 'webpack --help=verbose'. @@ -2801,7 +2796,6 @@ exports[`help should show help information using the "help serve --mode" option: exports[`help should show help information using the "help serve --mode" option: stdout 1`] = ` "Usage: webpack serve --mode Description: Defines the mode to pass to webpack. -Possible values: \\"development | production | none\\" To see list of all supported commands and options run 'webpack --help=verbose'. From f5994931107a63746f8c665176b0529c434effd6 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 7 Jul 2021 13:07:29 +0530 Subject: [PATCH 6/6] test: fix --- .../help.test.js.snap.devServer3.webpack4 | 13 ------------- .../help.test.js.snap.devServer4.webpack4 | 13 ------------- test/help/help.test.js | 12 ++++++++---- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 index 893a4280c37..5e9c6cb436b 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.devServer3.webpack4 @@ -2515,19 +2515,6 @@ CLI documentation: https://webpack.js.org/api/cli/. Made with ♥ by the webpack team." `; -exports[`help should show help information using the "help --cache-type" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` -"Usage: webpack --cache-type -Description: In memory caching. Filesystem caching. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - exports[`help should show help information using the "help --color" option: stderr 1`] = `""`; exports[`help should show help information using the "help --color" option: stdout 1`] = ` diff --git a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 index ca32b7ec7c2..170369e3ff3 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack4 @@ -2645,19 +2645,6 @@ CLI documentation: https://webpack.js.org/api/cli/. Made with ♥ by the webpack team." `; -exports[`help should show help information using the "help --cache-type" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` -"Usage: webpack --cache-type -Description: In memory caching. Filesystem caching. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - exports[`help should show help information using the "help --color" option: stderr 1`] = `""`; exports[`help should show help information using the "help --color" option: stdout 1`] = ` diff --git a/test/help/help.test.js b/test/help/help.test.js index d7ef6cda29c..f7f556bcf8e 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -1,6 +1,6 @@ "use strict"; -const { run, normalizeStderr, normalizeStdout } = require("../utils/test-utils"); +const { run, normalizeStderr, normalizeStdout, isWebpack5 } = require("../utils/test-utils"); describe("help", () => { it('should show help information using the "--help" option', async () => { @@ -245,9 +245,13 @@ describe("help", () => { it('should show help information using the "help --cache-type" option', async () => { const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--cache-type"]); - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); + if (isWebpack5) { + expect(exitCode).toBe(0); + expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); + expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); + } else { + expect(exitCode).toBe(2); + } }); it('should show help information using the "help --no-stats" option', async () => {