Skip to content

Commit

Permalink
fix(@angular/cli): add --version option
Browse files Browse the repository at this point in the history
This commit introduces the `--version` option, which will display the Angular CLI version when using `ng --version`.

Closes #27668

(cherry picked from commit 386d766)
  • Loading branch information
alan-agius4 authored and clydin committed May 21, 2024
1 parent f4670fc commit 41ab6c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/angular/cli/src/command-builder/command-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { colors } from '../utilities/color';
import { AngularWorkspace, getWorkspace } from '../utilities/config';
import { assertIsError } from '../utilities/error';
import { PackageManagerUtils } from '../utilities/package-manager';
import { VERSION } from '../utilities/version';
import { CommandContext, CommandModuleError } from './command-module';
import {
CommandModuleConstructor,
Expand Down Expand Up @@ -122,7 +123,7 @@ export async function runCommand(args: string[], logger: logging.Logger): Promis
.demandCommand(1, demandCommandFailureMessage)
.recommendCommands()
.middleware(normalizeOptionsMiddleware)
.version(false)
.version('version', 'Show Angular CLI version.', VERSION.full)
.showHelpOnFail(false)
.strict()
.fail((msg, err) => {
Expand Down
5 changes: 5 additions & 0 deletions tests/legacy-cli/e2e/tests/commands/help/help-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export default async function () {
'description': 'If provided, a new value for the given configuration key.',
'positional': 1,
},
{
'name': 'version',
'type': 'boolean',
'description': 'Show Angular CLI version.',
},
],
});

Expand Down

0 comments on commit 41ab6c8

Please sign in to comment.