File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
packages/@angular/cli/upgrade Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import * as path from 'path';
66
77import { CliConfig } from '../models/config' ;
88import { findUp } from '../utilities/find-up' ;
9+ import { requireProjectModule } from '../utilities/require-project-module' ;
910
1011const resolve = require ( 'resolve' ) ;
1112
@@ -83,10 +84,15 @@ export class Version {
8384 }
8485
8586 static assertAngularVersionIs2_3_1OrHigher ( projectRoot : string ) {
86- const angularCorePath = path . join ( projectRoot , 'node_modules/@angular/core' ) ;
87- const pkgJson = existsSync ( angularCorePath )
88- ? JSON . parse ( readFileSync ( path . join ( angularCorePath , 'package.json' ) , 'utf8' ) )
89- : null ;
87+ let pkgJson ;
88+ try {
89+ pkgJson = requireProjectModule ( projectRoot , '@angular/core/package.json' ) ;
90+ } catch ( _ ) {
91+ console . error ( bold ( red ( stripIndents `
92+ You seem to not be depending on "@angular/core". This is an error.
93+ ` ) ) ) ;
94+ process . exit ( 2 ) ;
95+ }
9096
9197 // Just check @angular /core.
9298 if ( pkgJson && pkgJson [ 'version' ] ) {
You can’t perform that action at this time.
0 commit comments