Skip to content

Commit

Permalink
feat(webpack-cli): add alias for version
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Apr 4, 2020
1 parent 6d825c4 commit 381ef9d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/webpack-cli/lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const resolveNegatedArgs = (args) => {
async function runCLI(cli, commandIsUsed) {
let args;
const helpFlagExists = isFlagPresent(process.argv, 'help');
const versionFlagExists = isFlagPresent(process.argv, 'version');
const versionFlagExists = isFlagPresent(process.argv, 'version') || isFlagPresent(process.argv, '-v');

if (helpFlagExists) {
cli.runHelp(process.argv);
Expand Down
1 change: 1 addition & 0 deletions packages/webpack-cli/lib/utils/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ module.exports = {
{
name: 'version',
usage: '--version',
alias: 'v',
type: Boolean,
group: BASIC_GROUP,
description: 'Get current version',
Expand Down
2 changes: 1 addition & 1 deletion test/version/version-multi-args.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('version flag with multiple arguments', () => {
});

it('outputs version with multiple commands', () => {
const { stdout, stderr } = run(__dirname, ['version', 'create']);
const { stdout, stderr } = run(__dirname, ['version', 'init']);
expect(stdout).toContain(pkgJSON.version);
expect(stderr).toHaveLength(0);
});
Expand Down
6 changes: 6 additions & 0 deletions test/version/version-single-arg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ describe('single version flag', () => {
expect(stdout).toContain(pkgJSON.version);
expect(stderr).toHaveLength(0);
});

it('outputs versions with alias syntax', () => {
const { stdout, stderr } = run(__dirname, ['-v']);
expect(stdout).toContain(pkgJSON.version);
expect(stderr).toHaveLength(0);
});
});

0 comments on commit 381ef9d

Please sign in to comment.