Skip to content

Commit 6cfb72a

Browse files
clydinhansl
authored andcommitted
fix(@angular/cli): support --version option
1 parent 98c2747 commit 6cfb72a

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

packages/angular/cli/models/command-runner.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ export async function runCommand(
115115

116116
// if no commands were found, use `help`.
117117
if (commandName === undefined) {
118-
commandName = 'help';
118+
if (args.length === 1 && args[0] === '--version') {
119+
commandName = 'version';
120+
} else {
121+
commandName = 'help';
122+
}
119123
}
120124

121125
let description: CommandDescription | null = null;
Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
import {deleteFile} from '../../utils/fs';
2-
import {ng} from '../../utils/process';
3-
4-
5-
export default function() {
6-
return ng('version')
7-
.then(() => deleteFile('angular.json'))
8-
// doesn't fail on a project with missing angular.json
9-
.then(() => ng('version'))
10-
// Doesn't fail outside a project.
11-
.then(() => process.chdir('/'))
12-
.then(() => ng('version'));
1+
import { deleteFile } from '../../utils/fs';
2+
import { ng } from '../../utils/process';
3+
4+
5+
export default async function() {
6+
const { stdout: commandOutput } = await ng('version');
7+
const { stdout: optionOutput } = await ng('--version');
8+
if (!optionOutput.includes('Angular CLI:')) {
9+
throw new Error('version not displayed');
10+
}
11+
if (commandOutput !== optionOutput) {
12+
throw new Error('version variants have differing output');
13+
}
14+
15+
// doesn't fail on a project with missing angular.json
16+
await deleteFile('angular.json');
17+
await ng('version');
18+
19+
// Doesn't fail outside a project.
20+
await process.chdir('/');
21+
await ng('version');
1322
}

0 commit comments

Comments
 (0)