Skip to content

Commit

Permalink
chore: improve error message for invalid progress value (#2014)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Nov 2, 2020
1 parent a994d4b commit 718e485
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/webpack-cli/README.md
Expand Up @@ -41,7 +41,7 @@ yarn add webpack-cli --dev
-c, --config string[] Provide path to webpack configuration file(s)
--config-name string[] Name of the configuration to use
-m, --merge Merge several configurations using webpack-merge
--progress Print compilation progress during build
--progress string, boolean Print compilation progress during build
--color Enables colors on console
--no-color Disable colors on console
--env string Environment passed to the configuration when it is a function
Expand Down
4 changes: 3 additions & 1 deletion packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js
Expand Up @@ -24,7 +24,9 @@ class WebpackCLIPlugin {

if (!progressPluginExists) {
if (typeof this.options.progress === 'string' && this.options.progress !== 'profile') {
logger.error(`Invalid ${this.options.progress} value for the progress option. Allowed value is profile.`);
logger.error(
`'${this.options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`,
);
process.exit(2);
}

Expand Down
2 changes: 1 addition & 1 deletion test/progress/progress-flag.test.js
Expand Up @@ -25,7 +25,7 @@ describe('progress flag', () => {
const { stderr, stdout, exitCode } = run(__dirname, ['--progress=unknown']);

expect(exitCode).toBe(2);
expect(stderr).toContain('Invalid unknown value for the progress option. Allowed value is profile.');
expect(stderr).toContain(`'unknown' is an invalid value for the --progress option. Only 'profile' is allowed.`);
expect(stdout).toBeFalsy();
});

Expand Down

0 comments on commit 718e485

Please sign in to comment.