chore(devkit): fix root when unit testing generators wrapped as schematics (#15506)
This commit is contained in:
parent
bfdd2eb5b5
commit
d0c38b39e7
@ -104,7 +104,21 @@ class DevkitTreeFromAngularDevkitTree implements Tree {
|
||||
private tree,
|
||||
private _root: string,
|
||||
private skipWritingConfigInOldFormat?: boolean
|
||||
) {}
|
||||
) {
|
||||
/**
|
||||
* When using the UnitTestTree from @angular-devkit/schematics/testing, the root is just `/`.
|
||||
* This causes a massive issue if `getProjects()` is used in the underlying generator because it
|
||||
* causes fast-glob to be set to work on the user's entire file system.
|
||||
*
|
||||
* Therefore, in this case, patch the root to match what Nx Devkit does and use /virtual instead.
|
||||
*/
|
||||
try {
|
||||
const { UnitTestTree } = require('@angular-devkit/schematics/testing');
|
||||
if (tree instanceof UnitTestTree && _root === '/') {
|
||||
this._root = '/virtual';
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
get root(): string {
|
||||
return this._root;
|
||||
|
||||
@ -55,7 +55,12 @@ const IGNORE_MATCHES_IN_PACKAGE = {
|
||||
],
|
||||
cli: ['nx'],
|
||||
cypress: ['cypress', '@angular-devkit/schematics', '@nrwl/cypress', 'vite'],
|
||||
devkit: ['@angular-devkit/architect', 'rxjs', 'webpack'],
|
||||
devkit: [
|
||||
'@angular-devkit/architect',
|
||||
'@angular-devkit/schematics',
|
||||
'rxjs',
|
||||
'webpack',
|
||||
],
|
||||
'eslint-plugin-nx': ['@angular-eslint/eslint-plugin'],
|
||||
jest: [
|
||||
'jest',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user