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(webpack-cli): add alias for version #1405

Merged
merged 1 commit into from
Apr 6, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webpack-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Options
-p, --prod Run production build
--mode string Defines the mode to pass to webpack
--no-mode Sets mode="none" which disables any default behavior
--version Get current version
-v, --version Get current version
--node-args string[] NodeJS flags
--stats type It instructs webpack on how to treat the stats
--verbose It tells webpack to output all the information
Expand Down
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);
});
});