Skip to content

Commit

Permalink
feat(@angular/cli): version shows ejected app or not
Browse files Browse the repository at this point in the history
And show the CLI config version if its different.
  • Loading branch information
hansl committed Feb 17, 2017
1 parent 7ac0d05 commit 6b53cd0
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions packages/@angular/cli/commands/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const Command = require('../ember-cli/lib/models/command');
import * as path from 'path';
import * as child_process from 'child_process';
import * as chalk from 'chalk';
import { CliConfig } from '../models/config';


const VersionCommand = Command.extend({
name: 'version',
Expand Down Expand Up @@ -40,6 +42,13 @@ const VersionCommand = Command.extend({

ngCliVersion = `local (v${pkg.version}, branch: ${gitBranch})`;
}
const config = CliConfig.fromProject();
if (config && config.config.project.version !== pkg.version) {
ngCliVersion += ` [${config.config.project.version}]`;
}
if (config && config.config.project.ejected) {
ngCliVersion += ' (e)';
}

if (projPkg) {
roots.forEach(root => {
Expand Down Expand Up @@ -76,12 +85,16 @@ const VersionCommand = Command.extend({
},

getVersion: function(moduleName: string): string {
const modulePkg = require(path.resolve(
this.project.root,
'node_modules',
moduleName,
'package.json'));
return modulePkg.version;
try {
const modulePkg = require(path.resolve(
this.project.root,
'node_modules',
moduleName,
'package.json'));
return modulePkg.version;
} catch (e) {
return 'error';
}
},

printVersion: function (module: string, version: string) {
Expand Down

0 comments on commit 6b53cd0

Please sign in to comment.