Skip to content

Commit f63f8c6

Browse files
author
Angular Builds
committed
cfa1649 refactor(@angular/cli): use standard node resolution methods where possible
1 parent d234a14 commit f63f8c6

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

commands/add-impl.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
88
* found in the LICENSE file at https://angular.io/license
99
*/
1010
const core_1 = require("@angular-devkit/core");
11-
const node_1 = require("@angular-devkit/core/node");
1211
const tools_1 = require("@angular-devkit/schematics/tools");
1312
const path_1 = require("path");
1413
const semver_1 = require("semver");
@@ -119,15 +118,11 @@ class AddCommand extends schematic_command_1.SchematicCommand {
119118
}
120119
isPackageInstalled(name) {
121120
try {
122-
node_1.resolve(name, {
123-
checkLocal: true,
124-
basedir: this.workspace.root,
125-
resolvePackageJson: true,
126-
});
121+
require.resolve(path_1.join(name, 'package.json'), { paths: [this.workspace.root] });
127122
return true;
128123
}
129124
catch (e) {
130-
if (!(e instanceof node_1.ModuleNotFoundException)) {
125+
if (e.code !== 'MODULE_NOT_FOUND') {
131126
throw e;
132127
}
133128
}
@@ -160,7 +155,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
160155
async findProjectVersion(name) {
161156
let installedPackage;
162157
try {
163-
installedPackage = node_1.resolve(name, { checkLocal: true, basedir: this.workspace.root, resolvePackageJson: true });
158+
installedPackage = require.resolve(path_1.join(name, 'package.json'), { paths: [this.workspace.root] });
164159
}
165160
catch (_a) { }
166161
if (installedPackage) {

lib/init.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require("symbol-observable");
1111
// symbol polyfill must go first
1212
// tslint:disable-next-line:ordered-imports import-groups
1313
const core_1 = require("@angular-devkit/core");
14-
const node_1 = require("@angular-devkit/core/node");
1514
const fs = require("fs");
1615
const path = require("path");
1716
const semver_1 = require("semver");
@@ -62,11 +61,7 @@ if (process.env['NG_CLI_PROFILING']) {
6261
}
6362
let cli;
6463
try {
65-
const projectLocalCli = node_1.resolve('@angular/cli', {
66-
checkGlobal: false,
67-
basedir: process.cwd(),
68-
preserveSymlinks: true,
69-
});
64+
const projectLocalCli = require.resolve('@angular/cli', { paths: [process.cwd()] });
7065
// This was run from a global, check local version.
7166
const globalVersion = new semver_1.SemVer(packageJson['version']);
7267
let localVersion;

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/cli",
3-
"version": "8.0.0-beta.10+33.a355e7d",
3+
"version": "8.0.0-beta.10+34.cfa1649",
44
"description": "CLI tool for Angular",
55
"main": "lib/cli/index.js",
66
"bin": {
@@ -28,11 +28,11 @@
2828
},
2929
"homepage": "https://github.com/angular/angular-cli",
3030
"dependencies": {
31-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#a355e7d",
32-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#a355e7d",
33-
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#a355e7d",
34-
"@schematics/angular": "github:angular/schematics-angular-builds#a355e7d",
35-
"@schematics/update": "github:angular/schematics-update-builds#a355e7d",
31+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#cfa1649",
32+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#cfa1649",
33+
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#cfa1649",
34+
"@schematics/angular": "github:angular/schematics-angular-builds#cfa1649",
35+
"@schematics/update": "github:angular/schematics-update-builds#cfa1649",
3636
"@yarnpkg/lockfile": "1.1.0",
3737
"debug": "^4.1.1",
3838
"ini": "1.3.5",

uniqueId

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Sat Mar 30 2019 01:23:40 GMT+0000 (Coordinated Universal Time)
1+
Sun Mar 31 2019 01:57:00 GMT+0000 (Coordinated Universal Time)

upgrade/version.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
Object.defineProperty(exports, "__esModule", { value: true });
1010
const core_1 = require("@angular-devkit/core");
11-
const node_1 = require("@angular-devkit/core/node");
1211
const path = require("path");
1312
const semver_1 = require("semver");
1413
class Version {
@@ -35,13 +34,9 @@ class Version {
3534
let angularPkgJson;
3635
let rxjsPkgJson;
3736
try {
38-
const resolveOptions = {
39-
basedir: projectRoot,
40-
checkGlobal: false,
41-
checkLocal: true,
42-
};
43-
const angularPackagePath = node_1.resolve('@angular/core/package.json', resolveOptions);
44-
const rxjsPackagePath = node_1.resolve('rxjs/package.json', resolveOptions);
37+
const resolveOptions = { paths: [projectRoot] };
38+
const angularPackagePath = require.resolve('@angular/core/package.json', resolveOptions);
39+
const rxjsPackagePath = require.resolve('rxjs/package.json', resolveOptions);
4540
angularPkgJson = require(angularPackagePath);
4641
rxjsPkgJson = require(rxjsPackagePath);
4742
}

0 commit comments

Comments
 (0)