From 4dd7069e4de67cb04c967332f6ac3d3d156028a7 Mon Sep 17 00:00:00 2001 From: aparziale Date: Wed, 8 Oct 2025 20:26:08 +0200 Subject: [PATCH] fix(core): ensure default path is set for control flow migration When running the control flow migration via `ng update`, the path parameter could be undefined. This change ensures a default value of './' is used when no path is explicitly provided, making the migration work consistently between `ng update` and `ng generate` commands. Fixes #63294 --- .../migrations/control-flow-migration/index.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/core/schematics/migrations/control-flow-migration/index.ts b/packages/core/schematics/migrations/control-flow-migration/index.ts index 2f897a7bbbf2..00879f11d716 100644 --- a/packages/core/schematics/migrations/control-flow-migration/index.ts +++ b/packages/core/schematics/migrations/control-flow-migration/index.ts @@ -24,11 +24,23 @@ interface Options { export function migrate(options: Options): Rule { return async (tree: Tree, context: SchematicContext) => { + const resolvedOptions = { + path: options.path ?? './', + format: options.format ?? true, + }; + let allPaths = []; const basePath = process.cwd(); let pathToMigrate: string | undefined; - if (options.path) { - pathToMigrate = normalizePath(join(basePath, options.path)); + + if (resolvedOptions.path) { + if (resolvedOptions.path.startsWith('..')) { + throw new SchematicsException( + 'Cannot run control flow migration outside of the current project.', + ); + } + + pathToMigrate = normalizePath(join(basePath, resolvedOptions.path)); if (pathToMigrate.trim() !== '') { allPaths.push(pathToMigrate); }