diff --git a/packages/angular-cli/blueprints/class/index.js b/packages/angular-cli/blueprints/class/index.js index 9ddfa1a2459a..cfdc7f376098 100644 --- a/packages/angular-cli/blueprints/class/index.js +++ b/packages/angular-cli/blueprints/class/index.js @@ -6,26 +6,26 @@ const getFiles = Blueprint.prototype.files; module.exports = { description: '', - anonymousOptions: [ - '' - ], - availableOptions: [ { name: 'spec', type: Boolean } ], normalizeEntityName: function (entityName) { - var parsedPath = dynamicPathParser(this.project, entityName); + var parsedPath = dynamicPathParser(this.project, entityName.split('.')[0]); this.dynamicPath = parsedPath; return parsedPath.name; }, locals: function (options) { - var classType = options.args [2] + const rawName = options.args[1]; + const nameParts = rawName.split('.') + .filter(part => part.length !== 0); + + const classType = nameParts[1]; this.fileName = stringUtils.dasherize(options.entity.name); if (classType) { - this.fileName += '.' + classType; + this.fileName += '.' + classType.toLowerCase(); } options.spec = options.spec !== undefined ? diff --git a/tests/acceptance/generate-class.spec.js b/tests/acceptance/generate-class.spec.js index 5ec94d056f30..dce2154ad118 100644 --- a/tests/acceptance/generate-class.spec.js +++ b/tests/acceptance/generate-class.spec.js @@ -43,8 +43,8 @@ describe('Acceptance: ng generate class', function () { }); }); - it('ng generate class my-class model', function () { - return ng(['generate', 'class', 'my-class', 'model']).then(() => { + it('ng generate class my-class.model', function () { + return ng(['generate', 'class', 'my-class.model']).then(() => { expect(existsSync(path.join(testPath, 'my-class.model.ts'))).to.equal(true); }); }); @@ -55,8 +55,8 @@ describe('Acceptance: ng generate class', function () { }); }); - it(`ng generate class shared${path.sep}my-class model`, function () { - return ng(['generate', 'class', 'shared/my-class', 'model']).then(() => { + it(`ng generate class shared${path.sep}my-class.model`, function () { + return ng(['generate', 'class', 'shared/my-class.model']).then(() => { expect(existsSync(path.join(testPath, 'shared', 'my-class.model.ts'))).to.equal(true); }); });