Skip to content

Commit

Permalink
feat(generate): specify class type via dot notation
Browse files Browse the repository at this point in the history
Closes angular#2155

BREAKING CHANGE: The ability to specify a class type via an additional arg has been replaced by combining the name and type args separated by a dot
  • Loading branch information
Brocco committed Oct 13, 2016
1 parent 2225027 commit 1210f02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions packages/angular-cli/blueprints/class/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ const getFiles = Blueprint.prototype.files;
module.exports = {
description: '',

anonymousOptions: [
'<class-type>'
],

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 ?
Expand Down
8 changes: 4 additions & 4 deletions tests/acceptance/generate-class.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand All @@ -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);
});
});
Expand Down

0 comments on commit 1210f02

Please sign in to comment.