Browse Source

Trim targetProject input before lookup

Ensures that leading and trailing whitespace is removed from the targetProject option before attempting to retrieve the project from the workspace. This prevents errors when users accidentally include extra spaces in the project name.
pull/23910/head
Fahri Gedik 11 months ago
parent
commit
cecec7505f
  1. 5
      npm/ng-packs/packages/schematics/src/commands/ai-config/index.ts

5
npm/ng-packs/packages/schematics/src/commands/ai-config/index.ts

@ -38,10 +38,11 @@ export default function (options: AiConfigSchema): Rule {
let targetPath = '/';
if (options.targetProject) {
const project = workspace.projects.get(options.targetProject);
const trimmedTargetProject = options.targetProject.trim();
const project = workspace.projects.get(trimmedTargetProject);
if (!project) {
throw new SchematicsException(
`Project "${options.targetProject}" not found in workspace.`
`Project "${trimmedTargetProject}" not found in workspace.`
);
}
targetPath = normalize(project.root);

Loading…
Cancel
Save