Skip to content

fix(@angular-devkit/schematics): running external schematics with yarn pnp #26109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
}

private resolve(name: string, requester?: string, references = new Set<string>()): string {
// Keep track of the package requesting the schematic, in order to avoid infinite recursion
if (requester) {
if (references.has(requester)) {
references.add(requester);
Expand Down Expand Up @@ -65,7 +66,16 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
throw new NodePackageDoesNotSupportSchematics(name);
}

collectionPath = this.resolve(schematics, packageJsonPath, references);
// If this is a relative path to the collection, then create the collection
// path in relation to the package path
if (schematics.startsWith('.')) {
const packageDirectory = dirname(packageJsonPath);
collectionPath = resolve(packageDirectory, schematics);
}
// Otherwise treat this as a package, and recurse to find the collection path
else {
collectionPath = this.resolve(schematics, packageJsonPath, references);
}
} catch (e) {
if ((e as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {
throw e;
Expand Down