Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show up cli flag aliases with webpack help <arg> #1647

Merged
merged 3 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/webpack-cli/lib/groups/HelpGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class HelpGroup {

const { bold, underline } = chalk.white;
const header = (head) => bold(underline(head));
const usage = chalk.keyword('orange')('webpack ' + options.usage);
const flagAlias = options.alias ? (isCommand ? ` ${options.alias} |` : ` -${options.alias},`) : '';
const usage = chalk.keyword('orange')(`webpack${flagAlias} ${options.usage}`);
const description = options.description;
const link = options.link;

Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-cli/lib/utils/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
name: 'init',
alias: 'c',
type: String,
usage: 'init | init <scaffold>',
usage: 'init [scaffold]',
description: 'Initialize a new webpack configuration',
},
{
Expand Down
2 changes: 1 addition & 1 deletion test/help/help-commands.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('commands help', () => {
it('gives precedence to earlier command in case of multiple commands', () => {
const { stdout, stderr } = run(__dirname, ['--help', 'init', 'info'], false);
expect(stdout).not.toContain(helpHeader);
expect(stdout).toContain('webpack init | init <scaffold>');
expect(stdout).toContain('webpack c | init [scaffold]');
expect(stderr).toHaveLength(0);
});
});
2 changes: 1 addition & 1 deletion test/help/help-flags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('commands help', () => {
it('shows flag help with valid flag', () => {
const { stdout, stderr } = run(__dirname, ['--help', '--merge'], false);
expect(stdout).not.toContain(helpHeader);
expect(stdout).toContain('webpack --merge <path to configuration to be merged>');
expect(stdout).toContain('webpack -m, --merge <path to configuration to be merged>');
expect(stderr).toHaveLength(0);
});

Expand Down
2 changes: 1 addition & 1 deletion test/help/help-multi-args.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('help cmd with multiple arguments', () => {
it('should output help for --version by taking precedence', () => {
const { stdout, stderr } = run(__dirname, ['--help', '--version'], false);
expect(stdout).not.toContain(helpHeader);
expect(stdout).toContain('webpack --version');
expect(stdout).toContain('webpack -v, --version');
expect(stderr).toHaveLength(0);
});
});
2 changes: 1 addition & 1 deletion test/info/info-help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const runInfo = (args) => {

const infoFlags = commands.find((c) => c.name === 'info').flags;

const usageText = 'webpack info [options]';
const usageText = 'webpack i | info [options]';
const descriptionText = 'Outputs information about your system and dependencies';

describe('should print help for info command', () => {
Expand Down