Skip to content

Commit

Permalink
feat: support command aliases with webpack-cli version (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored Jul 3, 2020
1 parent 25ef876 commit a637801
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/webpack-cli/lib/groups/HelpGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class HelpGroup {
outputVersion(externalPkg, commandsUsed, invalidArgs) {
if (externalPkg && commandsUsed.length === 1 && invalidArgs.length === 0) {
try {
if (commandsUsed.includes(externalPkg.name)) {
if ([externalPkg.alias, externalPkg.name].some((pkg) => commandsUsed.includes(pkg))) {
const { name, version } = require(`@webpack-cli/${defaultCommands[externalPkg.name]}/package.json`);
process.stdout.write(`\n${name} ${version}`);
} else {
Expand Down
7 changes: 7 additions & 0 deletions test/version/version-external-packages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ describe('version flag with external packages', () => {
expect(stderr).toHaveLength(0);
});

it('outputs version with the alias c for init', () => {
const { stdout, stderr } = run(__dirname, ['c', '--version'], false);
expect(stdout).toContain(initPkgJSON.version);
expect(stdout).toContain(cliPkgJSON.version);
expect(stderr).toHaveLength(0);
});

it('outputs version with info', () => {
const { stdout, stderr } = run(__dirname, ['info', '--version'], false);
expect(stdout).toContain(infoPkgJSON.version);
Expand Down

0 comments on commit a637801

Please sign in to comment.