Skip to content

Commit 8f2b1ce

Browse files
committed
feat(@angular/cli): version shows ejected app or not
And show the CLI config version if its different.
1 parent bb891df commit 8f2b1ce

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

packages/@angular/cli/commands/version.ts

+19-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const Command = require('../ember-cli/lib/models/command');
22
import * as path from 'path';
33
import * as child_process from 'child_process';
44
import * as chalk from 'chalk';
5+
import { CliConfig } from '../models/config';
6+
57

68
const VersionCommand = Command.extend({
79
name: 'version',
@@ -40,6 +42,13 @@ const VersionCommand = Command.extend({
4042

4143
ngCliVersion = `local (v${pkg.version}, branch: ${gitBranch})`;
4244
}
45+
const config = CliConfig.fromProject();
46+
if (config && config.config.project.version !== pkg.version) {
47+
ngCliVersion += ` [${config.config.project.version}]`;
48+
}
49+
if (config && config.config.project.ejected) {
50+
ngCliVersion += ' (e)';
51+
}
4352

4453
if (projPkg) {
4554
roots.forEach(root => {
@@ -76,12 +85,16 @@ const VersionCommand = Command.extend({
7685
},
7786

7887
getVersion: function(moduleName: string): string {
79-
const modulePkg = require(path.resolve(
80-
this.project.root,
81-
'node_modules',
82-
moduleName,
83-
'package.json'));
84-
return modulePkg.version;
88+
try {
89+
const modulePkg = require(path.resolve(
90+
this.project.root,
91+
'node_modules',
92+
moduleName,
93+
'package.json'));
94+
return modulePkg.version;
95+
} catch (e) {
96+
return 'error';
97+
}
8598
},
8699

87100
printVersion: function (module: string, version: string) {

0 commit comments

Comments
 (0)