From ac93839d694929fdf16c610994a369d4efb2823a Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Fri, 9 Aug 2024 12:43:10 +0200 Subject: [PATCH] fix(migrations): avoid migrating route component in tests (#57317) The migration was migrating all files in a project (like most migrations). As there is no gain in migrating components used in test files. Excluding the test files reduces the migration noise. PR Close #57317 --- .../schematics/ng-generate/route-lazy-loading/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/core/schematics/ng-generate/route-lazy-loading/index.ts b/packages/core/schematics/ng-generate/route-lazy-loading/index.ts index 5ee0e2c9975..f8f494d5a4f 100644 --- a/packages/core/schematics/ng-generate/route-lazy-loading/index.ts +++ b/packages/core/schematics/ng-generate/route-lazy-loading/index.ts @@ -22,14 +22,13 @@ interface Options { export default function (options: Options): Rule { return async (tree, context) => { - const {buildPaths, testPaths} = await getProjectTsConfigPaths(tree); + const {buildPaths} = await getProjectTsConfigPaths(tree); const basePath = process.cwd(); - const allPaths = [...buildPaths, ...testPaths]; // TS and Schematic use paths in POSIX format even on Windows. This is needed as otherwise // string matching such as `sourceFile.fileName.startsWith(pathToMigrate)` might not work. const pathToMigrate = normalizePath(join(basePath, options.path)); - if (!allPaths.length) { + if (!buildPaths.length) { throw new SchematicsException( 'Could not find any tsconfig file. Cannot run the route lazy loading migration.', ); @@ -38,7 +37,7 @@ export default function (options: Options): Rule { let migratedRoutes: RouteMigrationData[] = []; let skippedRoutes: RouteMigrationData[] = []; - for (const tsconfigPath of allPaths) { + for (const tsconfigPath of buildPaths) { const {migratedRoutes: migrated, skippedRoutes: skipped} = standaloneRoutesMigration( tree, tsconfigPath,