Skip to content

fix(@angular/cli): use require for @angular/core check #7601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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