Skip to content

Commit a637801

Browse files
feat: support command aliases with webpack-cli version (#1664)
1 parent 25ef876 commit a637801

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/webpack-cli/lib/groups/HelpGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class HelpGroup {
4949
outputVersion(externalPkg, commandsUsed, invalidArgs) {
5050
if (externalPkg && commandsUsed.length === 1 && invalidArgs.length === 0) {
5151
try {
52-
if (commandsUsed.includes(externalPkg.name)) {
52+
if ([externalPkg.alias, externalPkg.name].some((pkg) => commandsUsed.includes(pkg))) {
5353
const { name, version } = require(`@webpack-cli/${defaultCommands[externalPkg.name]}/package.json`);
5454
process.stdout.write(`\n${name} ${version}`);
5555
} else {

test/version/version-external-packages.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ describe('version flag with external packages', () => {
1717
expect(stderr).toHaveLength(0);
1818
});
1919

20+
it('outputs version with the alias c for init', () => {
21+
const { stdout, stderr } = run(__dirname, ['c', '--version'], false);
22+
expect(stdout).toContain(initPkgJSON.version);
23+
expect(stdout).toContain(cliPkgJSON.version);
24+
expect(stderr).toHaveLength(0);
25+
});
26+
2027
it('outputs version with info', () => {
2128
const { stdout, stderr } = run(__dirname, ['info', '--version'], false);
2229
expect(stdout).toContain(infoPkgJSON.version);

0 commit comments

Comments
 (0)