Skip to content

Commit 5e9f462

Browse files
committed
chore: generation paths are fully dynamic & supports --flat for components/directives/pipes/services
This is a step in aligning with the style guide and will provide the flexibility needed Related to #316 Closes #401
1 parent 673b79c commit 5e9f462

File tree

18 files changed

+93
-41
lines changed

18 files changed

+93
-41
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
import {provide} from 'angular2/core';
1313
import {<%= classifiedModuleName %>} from './<%= dasherizedModuleName %>';
1414

15-
1615
describe('<%= classifiedModuleName %> Component', () => {
1716

1817
beforeEachProviders((): any[] => []);
File renamed without changes.

addon/ng2/blueprints/component/index.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
var path = require('path');
12
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
23

34
module.exports = {
45
description: '',
6+
7+
availableOptions: [
8+
{ name: 'flat', type: Boolean, default: false, aliases: ['f'] }
9+
],
510

611
normalizeEntityName: function (entityName) {
712
var parsedPath = dynamicPathParser(this.project, entityName);
@@ -10,20 +15,22 @@ module.exports = {
1015
return parsedPath.name;
1116
},
1217

13-
locals: function () {
18+
locals: function (options) {
1419
return {
15-
dynamicPath: this.dynamicPath.dir
20+
dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''),
21+
flat: options.flat
1622
};
1723
},
1824

19-
fileMapTokens: function () {
25+
fileMapTokens: function (options) {
2026
// Return custom template variables here.
2127
return {
22-
__name__: () => {
23-
return this.dynamicPath.name;
24-
},
2528
__path__: () => {
26-
return this.dynamicPath.dir;
29+
var dir = this.dynamicPath.dir;
30+
if (!options.locals.flat) {
31+
dir += path.sep + options.dasherizedModuleName;
32+
}
33+
return dir;
2734
}
2835
};
2936
}
File renamed without changes.
File renamed without changes.

addon/ng2/blueprints/directive/index.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
var path = require('path');
12
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
23

34
module.exports = {
45
description: '',
6+
7+
availableOptions: [
8+
{ name: 'flat', type: Boolean, default: false, aliases: ['f'] }
9+
],
510

611
normalizeEntityName: function (entityName) {
712
var parsedPath = dynamicPathParser(this.project, entityName);
@@ -10,20 +15,22 @@ module.exports = {
1015
return parsedPath.name;
1116
},
1217

13-
locals: function () {
18+
locals: function (options) {
1419
return {
15-
dynamicPath: this.dynamicPath.dir
20+
dynamicPath: this.dynamicPath.dir,
21+
flat: options.flat
1622
};
1723
},
1824

19-
fileMapTokens: function () {
25+
fileMapTokens: function (options) {
2026
// Return custom template variables here.
2127
return {
22-
__name__: () => {
23-
return this.dynamicPath.name;
24-
},
2528
__path__: () => {
26-
return this.dynamicPath.dir;
29+
var dir = this.dynamicPath.dir;
30+
if (!options.locals.flat) {
31+
dir += path.sep + options.dasherizedModuleName;
32+
}
33+
return dir;
2734
}
2835
};
2936
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)