Skip to content

Commit

Permalink
fix(@angular/cli): use require for @angular/core check
Browse files Browse the repository at this point in the history
This should help with linked node_module scenarios.
  • Loading branch information
filipesilva committed Sep 6, 2017
1 parent 2d63ed0 commit ec67c9a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/@angular/cli/upgrade/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as path from 'path';

import {CliConfig} from '../models/config';
import {findUp} from '../utilities/find-up';
import {requireProjectModule} from '../utilities/require-project-module';

const resolve = require('resolve');

Expand Down Expand Up @@ -83,10 +84,15 @@ export class Version {
}

static assertAngularVersionIs2_3_1OrHigher(projectRoot: string) {
const angularCorePath = path.join(projectRoot, 'node_modules/@angular/core');
const pkgJson = existsSync(angularCorePath)
? JSON.parse(readFileSync(path.join(angularCorePath, 'package.json'), 'utf8'))
: null;
let pkgJson;
try {
pkgJson = requireProjectModule(projectRoot, '@angular/core/package.json');
} catch (_) {
console.error(bold(red(stripIndents`
You seem to not be depending on "@angular/core". This is an error.
`)));
process.exit(2);
}

// Just check @angular/core.
if (pkgJson && pkgJson['version']) {
Expand Down

0 comments on commit ec67c9a

Please sign in to comment.