Skip to content

Commit

Permalink
fix: update usage info (#2594)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored Apr 5, 2021
1 parent 4617050 commit 9d07d67
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,9 @@ Commands:
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.
loader|l [output-path] Scaffold a loader.
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [new-config-path] Migrate a configuration to a new version.
plugin|p [output-path] Scaffold a plugin.
plugin|p [output-path] [options] Scaffold a plugin.
serve|s [entries...] [options] Run the webpack dev server.
version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
watch|w [entries...] [options] Run webpack and watch for files changes.
Expand Down
2 changes: 1 addition & 1 deletion packages/generators/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class GeneratorsCommand {
name: 'plugin [output-path]',
alias: 'p',
description: 'Scaffold a plugin.',
usage: '[output-path]',
usage: '[output-path] [options]',
pkg: '@webpack-cli/generators',
},
[
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ npx webpack-cli --help verbose
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.
loader|l [output-path] Scaffold a loader.
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [new-config-path] Migrate a configuration to a new version.
plugin|p [output-path] Scaffold a plugin.
plugin|p [output-path] [options] Scaffold a plugin.
serve|s [entries...] [options] Run the webpack dev server.
version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
watch|w [entries...] [options] Run webpack and watch for files changes.
Expand Down
2 changes: 1 addition & 1 deletion test/help/__snapshots__/help.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ Made with ♥ by the webpack team."
`;

exports[`help should show help information for 'plugin' command using the "--help" option 1`] = `
"Usage: webpack plugin|p [output-path]
"Usage: webpack plugin|p [output-path] [options]

Scaffold a plugin.

Expand Down
2 changes: 1 addition & 1 deletion test/help/__snapshots__/help.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Made with ♥ by the webpack team."
`;

exports[`help should show help information for 'plugin' command using the "--help" option 1`] = `
"Usage: webpack plugin|p [output-path]
"Usage: webpack plugin|p [output-path] [options]

Scaffold a plugin.

Expand Down
34 changes: 17 additions & 17 deletions test/help/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,51 +82,51 @@ describe('help', () => {
{
name: 'init',
alias: 'c',
helpOutput: 'webpack init|c [generation-path] [options]',
usage: 'webpack init|c [generation-path] [options]',
},
{
name: 'info',
alias: 'i',
helpOutput: 'webpack info|i [options]',
usage: 'webpack info|i [options]',
},
{
name: 'loader',
alias: 'l',
helpOutput: 'webpack loader|l [output-path]',
usage: 'webpack loader|l [output-path] [options]',
},
{
name: 'migrate',
alias: 'm',
helpOutput: 'webpack migrate|m <config-path> [new-config-path]',
usage: 'webpack migrate|m <config-path> [new-config-path]',
},
{
name: 'plugin',
alias: 'p',
helpOutput: 'webpack plugin|p [output-path]',
usage: 'webpack plugin|p [output-path] [options]',
},
{
name: 'configtest',
alias: 't',
helpOutput: 'webpack configtest|t [config-path]',
usage: 'webpack configtest|t [config-path]',
},
{
name: 'watch',
alias: 'w',
helpOutput: 'webpack watch|w [entries...] [options]',
usage: 'webpack watch|w [entries...] [options]',
},
{
name: 'serve',
alias: 's',
helpOutput: 'webpack serve|s [entries...] [options]',
usage: 'webpack serve|s [entries...] [options]',
},
{
name: 'build',
alias: 'b',
helpOutput: 'webpack build|bundle|b [entries...] [options]',
usage: 'webpack build|bundle|b [entries...] [options]',
},
];

commands.forEach(({ name, alias, helpOutput }) => {
commands.forEach(({ name, alias, usage }) => {
it(`should show help information for '${name}' command using the "--help" option`, async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [name, '--help']);

Expand All @@ -141,39 +141,39 @@ describe('help', () => {

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain(helpOutput);
expect(stdout).toContain(usage);
});

it(`should show help information for '${name}' command using command syntax`, async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ['help', name]);

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain(helpOutput);
expect(stdout).toContain(usage);
});

it(`should show help information for '${alias}' command using the "--help" option`, async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [alias, '--help']);

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain(helpOutput);
expect(stdout).toContain(usage);
});

it(`should show help information for '${alias}' command using the "--help verbose" option`, async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [alias, '--help', 'verbose']);

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain(helpOutput);
expect(stdout).toContain(usage);
});

it(`should show help information for '${alias}' command using command syntax`, async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ['help', alias]);

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain(helpOutput);
expect(stdout).toContain(usage);
});

it(`should show help information for '${name}' and respect the "--color" flag using the "--help" option`, async () => {
Expand All @@ -182,7 +182,7 @@ describe('help', () => {
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain('\x1b[1m');
expect(stdout).toContain(helpOutput);
expect(stdout).toContain(usage);

if (!isMacOS) {
expect(stdout).toContain('Made with ♥ by the webpack team');
Expand All @@ -195,7 +195,7 @@ describe('help', () => {
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).not.toContain('\x1b[1m');
expect(stdout).toContain(helpOutput);
expect(stdout).toContain(usage);

if (!isMacOS) {
expect(stdout).toContain('Made with ♥ by the webpack team');
Expand Down

0 comments on commit 9d07d67

Please sign in to comment.