From 053731d26d906d480a7b1a1e8063c575fb80a81c Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 19 Sep 2018 21:23:37 -0400 Subject: [PATCH 1/2] fix(@angular/cli): relax compatible angular check package location --- packages/angular/cli/upgrade/version.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/packages/angular/cli/upgrade/version.ts b/packages/angular/cli/upgrade/version.ts index a24b87231fd1..5e92a32bc8ed 100644 --- a/packages/angular/cli/upgrade/version.ts +++ b/packages/angular/cli/upgrade/version.ts @@ -41,17 +41,6 @@ export class Version { let angularPkgJson; let rxjsPkgJson; - const isInside = (base: string, potential: string): boolean => { - const absoluteBase = path.resolve(base); - const absolutePotential = path.resolve(potential); - const relativePotential = path.relative(absoluteBase, absolutePotential); - if (!relativePotential.startsWith('..') && !path.isAbsolute(relativePotential)) { - return true; - } - - return false; - }; - try { const resolveOptions = { basedir: projectRoot, @@ -61,11 +50,6 @@ export class Version { const angularPackagePath = resolve('@angular/core/package.json', resolveOptions); const rxjsPackagePath = resolve('rxjs/package.json', resolveOptions); - if (!isInside(projectRoot, angularPackagePath) - || !isInside(projectRoot, rxjsPackagePath)) { - throw new Error(); - } - angularPkgJson = require(angularPackagePath); rxjsPkgJson = require(rxjsPackagePath); } catch { From ba47c03f001089b548cb2a25c4afa69686cb86d0 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 20 Sep 2018 11:28:29 -0400 Subject: [PATCH 2/2] fix(@angular-devkit/build-angular): fully resolve project modules --- .../utilities/require-project-module.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/require-project-module.ts b/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/require-project-module.ts index 18c3cc4cf036..ec1eed116dca 100644 --- a/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/require-project-module.ts +++ b/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/require-project-module.ts @@ -5,19 +5,18 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -// tslint:disable -// TODO: cleanup this file, it's copied as is from Angular CLI. -import * as fs from 'fs'; -import * as path from 'path'; +import { resolve } from '@angular-devkit/core/node'; // Resolve dependencies within the target project. export function resolveProjectModule(root: string, moduleName: string) { - const rootModules = path.join(root, 'node_modules'); - if (fs.existsSync(rootModules)) { - return require.resolve(moduleName, { paths: [rootModules] }); - } else { - return require.resolve(moduleName, { paths: [root] }); - } + return resolve( + moduleName, + { + basedir: root, + checkGlobal: false, + checkLocal: true, + }, + ); } // Require dependencies within the target project.