mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 02:54:21 +08:00
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
This commit is contained in:
parent
ace02f6c2a
commit
ef360dd7f8
@ -40,7 +40,6 @@ export declare class NodeJsSyncHost implements virtualFs.Host<fs.Stats> {
|
||||
}
|
||||
|
||||
export declare class NodeModuleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements core_experimental.jobs.Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
constructor(_resolveLocal?: boolean, _resolveGlobal?: boolean);
|
||||
protected _resolve(name: string): string | null;
|
||||
get<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: core_experimental.jobs.JobName): Observable<core_experimental.jobs.JobHandler<A, I, O> | null>;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import { experimental, json, workspaces } from '@angular-devkit/core';
|
||||
import { resolve } from '@angular-devkit/core/node';
|
||||
import * as path from 'path';
|
||||
import { BuilderInfo } from '../src';
|
||||
import { Schema as BuilderSchema } from '../src/builders-schema';
|
||||
@ -56,11 +55,8 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
|
||||
throw new Error('No builder name specified.');
|
||||
}
|
||||
|
||||
const packageJsonPath = resolve(packageName, {
|
||||
basedir: this._root,
|
||||
checkLocal: true,
|
||||
checkGlobal: true,
|
||||
resolvePackageJson: true,
|
||||
const packageJsonPath = require.resolve(packageName + '/package.json', {
|
||||
paths: [this._root],
|
||||
});
|
||||
|
||||
const packageJson = require(packageJsonPath);
|
||||
|
@ -7,7 +7,6 @@
|
||||
*/
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { JsonValue, experimental as core_experimental, schema } from '../../../src';
|
||||
import { ModuleNotFoundException, resolve } from '../../resolve';
|
||||
|
||||
export class NodeModuleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue,
|
||||
MinimumInputValueT extends JsonValue = JsonValue,
|
||||
@ -15,18 +14,12 @@ export class NodeModuleJobRegistry<MinimumArgumentValueT extends JsonValue = Jso
|
||||
> implements core_experimental.jobs.Registry<MinimumArgumentValueT,
|
||||
MinimumInputValueT,
|
||||
MinimumOutputValueT> {
|
||||
public constructor(private _resolveLocal = true, private _resolveGlobal = false) {
|
||||
}
|
||||
|
||||
protected _resolve(name: string): string | null {
|
||||
try {
|
||||
return resolve(name, {
|
||||
checkLocal: this._resolveLocal,
|
||||
checkGlobal: this._resolveGlobal,
|
||||
basedir: __dirname,
|
||||
});
|
||||
return require.resolve(name);
|
||||
} catch (e) {
|
||||
if (e instanceof ModuleNotFoundException) {
|
||||
if (e.code === 'MODULE_NOT_FOUND') {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
|
Loading…
x
Reference in New Issue
Block a user