diff --git a/packages/@angular/cli/commands/generate.ts b/packages/@angular/cli/commands/generate.ts index 059c71e0b6f0..48efce31a092 100644 --- a/packages/@angular/cli/commands/generate.ts +++ b/packages/@angular/cli/commands/generate.ts @@ -72,6 +72,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); }, diff --git a/tests/e2e/tests/generate/generate-name-error.ts b/tests/e2e/tests/generate/generate-name-error.ts new file mode 100644 index 000000000000..2fb0583ca514 --- /dev/null +++ b/tests/e2e/tests/generate/generate-name-error.ts @@ -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'))); +}