Skip to content

Commit ef360dd

Browse files
clydinmgechev
authored andcommitted
refactor(@angular-devkit/architect): use standard node resolution methods where possible (#15622)
* refactor(@angular-devkit/architect): use standard node resolution methods where possible * refactor(@angular-devkit/core): use standard node resolution methods where possible
1 parent ace02f6 commit ef360dd

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

etc/api/angular_devkit/core/node/_golden-api.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export declare class NodeJsSyncHost implements virtualFs.Host<fs.Stats> {
4040
}
4141

4242
export declare class NodeModuleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements core_experimental.jobs.Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
43-
constructor(_resolveLocal?: boolean, _resolveGlobal?: boolean);
4443
protected _resolve(name: string): string | null;
4544
get<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: core_experimental.jobs.JobName): Observable<core_experimental.jobs.JobHandler<A, I, O> | null>;
4645
}

packages/angular_devkit/architect/node/node-modules-architect-host.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { experimental, json, workspaces } from '@angular-devkit/core';
9-
import { resolve } from '@angular-devkit/core/node';
109
import * as path from 'path';
1110
import { BuilderInfo } from '../src';
1211
import { Schema as BuilderSchema } from '../src/builders-schema';
@@ -56,11 +55,8 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
5655
throw new Error('No builder name specified.');
5756
}
5857

59-
const packageJsonPath = resolve(packageName, {
60-
basedir: this._root,
61-
checkLocal: true,
62-
checkGlobal: true,
63-
resolvePackageJson: true,
58+
const packageJsonPath = require.resolve(packageName + '/package.json', {
59+
paths: [this._root],
6460
});
6561

6662
const packageJson = require(packageJsonPath);

packages/angular_devkit/core/node/experimental/jobs/job-registry.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,19 @@
77
*/
88
import { Observable, of } from 'rxjs';
99
import { JsonValue, experimental as core_experimental, schema } from '../../../src';
10-
import { ModuleNotFoundException, resolve } from '../../resolve';
1110

1211
export class NodeModuleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue,
1312
MinimumInputValueT extends JsonValue = JsonValue,
1413
MinimumOutputValueT extends JsonValue = JsonValue,
1514
> implements core_experimental.jobs.Registry<MinimumArgumentValueT,
1615
MinimumInputValueT,
1716
MinimumOutputValueT> {
18-
public constructor(private _resolveLocal = true, private _resolveGlobal = false) {
19-
}
2017

2118
protected _resolve(name: string): string | null {
2219
try {
23-
return resolve(name, {
24-
checkLocal: this._resolveLocal,
25-
checkGlobal: this._resolveGlobal,
26-
basedir: __dirname,
27-
});
20+
return require.resolve(name);
2821
} catch (e) {
29-
if (e instanceof ModuleNotFoundException) {
22+
if (e.code === 'MODULE_NOT_FOUND') {
3023
return null;
3124
}
3225
throw e;

0 commit comments

Comments
 (0)