bug: running "external" schematics in yarn pnp workspace #25648
Labels
area: @angular-devkit/schematics
freq1: low
Only reported by a handful of users who observe it rarely
severity3: broken
type: bug/fix
I'm finally getting around to moving a library project that uses
@schematics/angular
to use PnP, and discovered an issue with some code in theNodeModulesEngineHost
within@angular-devkit/schematics
. From my code, within a unit test, we're using theSchematicTestRunner
'srunExternalSchematic
function to generate a test project. Running that function from within a pnp environment is throwing the following error:This code seems to be improperly joining the
collection.json
path and thepackage.json
path (/node_modules/@schematics/angular/collection.json/package.json):angular-cli/packages/angular_devkit/schematics/tools/node-module-engine-host.ts
Line 61 in c34bbb8
This is the code we're running within our test:
It seems that the code is trying to blindly grab that path, knowing that this case will fail and hit the catch block, since it then tries an alternative approach just after that. So, my guess is where it's checking the error type, to decide whether to absorb the error or re-throw, it needs to consider this error type too (
ENOTDIR
)?angular-cli/packages/angular_devkit/schematics/tools/node-module-engine-host.ts
Lines 69 to 73 in c34bbb8
Seeing as this code isn't in the test-specific class, I suspect (but haven't verified) this might also fail for the
@angular-devkit/schematics
externalSchematics
function.Reproduction Repo: https://github.com/michaelfaith/ng-schematics-yarn-pnp-bug
Originally posted by @michaelfaith in #16980 (comment)
The text was updated successfully, but these errors were encountered: