Skip to content

Commit

Permalink
fix(@angular/cli): fix leading digit in file names from generate command
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoVaranda authored and Brocco committed May 24, 2017
1 parent 2b0d935 commit 8683c3c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/@angular/cli/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export default Command.extend({
`The \`ng generate ${name}\` command requires a name to be specified.`);
}

if (/^\d/.test(rawArgs[1])) {
SilentError.debugOrThrow('@angular/cli/commands/generate',
`The \`ng generate ${name} ${rawArgs[1]}\` file name cannot begin with a digit.`);
}

rawArgs[0] = blueprint.name;
this.registerOptions(blueprint);
},
Expand Down
9 changes: 9 additions & 0 deletions tests/e2e/tests/generate/generate-name-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {ng} from '../../utils/process';
import {expectToFail} from '../../utils/utils';


export default function() {
return Promise.resolve()
.then(() => expectToFail(() =>
ng('generate', 'component', '1my-component')));
}

0 comments on commit 8683c3c

Please sign in to comment.