mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user