Skip to content

Commit

Permalink
feat(blueprints): add enum blueprint.
Browse files Browse the repository at this point in the history
* Adds a basic blueprint for a typescript enum.

Closes #707
  • Loading branch information
devversion committed May 13, 2016
1 parent 679d0e6 commit eddb354
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addon/ng2/blueprints/enum/files/__path__/__name__.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum <%= classifiedModuleName %> {

}
44 changes: 44 additions & 0 deletions addon/ng2/blueprints/enum/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const stringUtils = require('ember-cli-string-utils');
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
var addBarrelRegistration = require('../../utilities/barrel-management');

module.exports = {
description: '',

normalizeEntityName: function (entityName) {
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;
return parsedPath.name;
},

locals: function (options) {
this.fileName = stringUtils.dasherize(options.entity.name);

return {
dynamicPath: this.dynamicPath.dir,
flat: options.flat,
fileName: this.fileName
};
},

fileMapTokens: function () {
// Return custom template variables here.
return {
__path__: () => {
this.generatePath = this.dynamicPath.dir;
return this.generatePath;
},
__name__: () => {
return this.fileName;
}
};
},

afterInstall: function() {
return addBarrelRegistration(
this,
this.generatePath,
this.fileName);
}
};
1 change: 1 addition & 0 deletions addon/ng2/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const aliasMap = {
'cl': 'class',
'c': 'component',
'd': 'directive',
'e': 'enum',
'p': 'pipe',
'r': 'route',
's': 'service'
Expand Down

0 comments on commit eddb354

Please sign in to comment.