From c30618893901bec3a122437bacfc2fd85424cfa0 Mon Sep 17 00:00:00 2001 From: aparziale Date: Wed, 8 Oct 2025 17:47:19 +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 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/core/schematics/migrations/control-flow-migration/index.ts b/packages/core/schematics/migrations/control-flow-migration/index.ts index 0a32476ad1c6..73721b9943c3 100644 --- a/packages/core/schematics/migrations/control-flow-migration/index.ts +++ b/packages/core/schematics/migrations/control-flow-migration/index.ts @@ -26,17 +26,24 @@ interface Options { export function migrate(options: Options): Rule { return async (tree: Tree, context: SchematicContext) => { + // Apply default values from schema when not provided by the migration system + const resolvedOptions = { + path: options.path ?? './', + format: options.format ?? true, + }; + let allPaths = []; const basePath = process.cwd(); let pathToMigrate: string | undefined; - if (options.path) { - if (options.path.startsWith('..')) { + + if (resolvedOptions.path) { + if (resolvedOptions.path.startsWith('..')) { throw new SchematicsException( 'Cannot run control flow migration outside of the current project.', ); } - pathToMigrate = normalizePath(join(basePath, options.path)); + pathToMigrate = normalizePath(join(basePath, resolvedOptions.path)); if (pathToMigrate.trim() !== '') { allPaths.push(pathToMigrate); }