Skip to content

Commit

Permalink
fix(@schematics/angular): validate project name before prompts
Browse files Browse the repository at this point in the history
When an invalid project name is given, throw an error before going through prompts.

Closes #14994

(cherry picked from commit a8c63a7)
  • Loading branch information
kgajera authored and alan-agius4 committed Jul 7, 2020
1 parent 07f93b7 commit 519eb6c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/schematics/angular/ng-new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
RepositoryInitializerTask,
} from '@angular-devkit/schematics/tasks';
import { Schema as ApplicationOptions } from '../application/schema';
import { validateProjectName } from '../utility/validation';
import { Schema as WorkspaceOptions } from '../workspace/schema';
import { Schema as NgNewOptions } from './schema';

Expand All @@ -33,6 +34,8 @@ export default function(options: NgNewOptions): Rule {
throw new SchematicsException(`Invalid options, "name" is required.`);
}

validateProjectName(options.name);

if (!options.directory) {
options.directory = options.name;
}
Expand Down

0 comments on commit 519eb6c

Please sign in to comment.