Skip to content

Commit 5ab0024

Browse files
committed
feat: merge ouputCommand into outputHelp
1 parent 4f19ad4 commit 5ab0024

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

lib/groups/help.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ class HelpGroup {
88
l() {
99
const c = chalk.cyan;
1010
}
11-
outputHelp() {
12-
process.stdout.write(this.run().outputOptions.help);
11+
outputHelp(command=null) {
12+
if (command != null) {
13+
const commands = require('../utils/commands').info;
14+
const options = commands.find(cmd => (cmd.name == command || cmd.alias == command));
15+
const { bold } = chalk.white;
16+
const usage = chalk.keyword('orange')('webpack ' + options.usage);
17+
const description = options.description;
18+
process.stdout.write(`${bold('Usage')}: ${usage}\n${bold('Description')}: ${description}\n`);
19+
} else {
20+
process.stdout.write(this.run().outputOptions.help);
21+
}
1322
process.stdout.write('\n Made with ♥️ by the webpack team \n');
1423
}
1524

@@ -20,16 +29,6 @@ class HelpGroup {
2029
process.stdout.write(`\nwebpack ${webpack.version}\n`);
2130
}
2231

23-
outputCommand(command) {
24-
const commands = require('../utils/commands').info;
25-
const options = commands.find(cmd => (cmd.name == command || cmd.alias == command));
26-
const { bold } = chalk.white;
27-
const usage = chalk.keyword('orange')('webpack ' + options.usage);
28-
const description = options.description;
29-
process.stdout.write(`${bold('Usage')}: ${usage}\n${bold('Description')}: ${description}\n`);
30-
process.stdout.write('\n Made with ♥️ by the webpack team \n');
31-
}
32-
3332
run() {
3433
const { underline, bold } = chalk.white
3534
const o = s => chalk.keyword('orange')(s);

lib/webpack-cli.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ class WebpackCLI extends GroupHelper {
169169
args.forEach(arg => {
170170
if (Commands.includes(arg)) command = arg;
171171
});
172-
if (command != null) return new HelpGroup().outputCommand(command);
173-
return new HelpGroup().outputHelp();
172+
return new HelpGroup().outputHelp(command);
174173
}
175174

176175
runVersion() {

0 commit comments

Comments
 (0)