Skip to content

Commit e802a8f

Browse files
committed
fix(paths): allow specifying paths to a component when generating
When generating a component allow to specify the path the where the component will go `ng generate component foo/bar/person` will create the component (and all associated files) in the directory `[project-root]/src/app/foo/bar/person/` Closes #267
1 parent 6cad6c3 commit e802a8f

File tree

6 files changed

+23
-25
lines changed

6 files changed

+23
-25
lines changed
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
var stringUtils = require('ember-cli/lib/utilities/string');
1+
var component = require('../component');
22

3-
module.exports = {
4-
description: ''
5-
6-
//locals: function(options) {
7-
// // Return custom template variables here.
8-
// return {
9-
//
10-
// };
11-
//}
12-
13-
// afterInstall: function(options) {
14-
// // Perform extra work here.
15-
// }
16-
};
3+
module.exports = component;
Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
var stringUtils = require('ember-cli/lib/utilities/string');
2+
var path = require('path');
23

34
module.exports = {
4-
description: ''
5+
description: '',
56

6-
//locals: function(options) {
7-
// // Return custom template variables here.
8-
// return {
9-
//
10-
// };
11-
//}
7+
locals: function(options) {
8+
var parsedPath = path.parse(options.entity.name);
9+
// build the locals for generating the name & path
10+
return {
11+
name: parsedPath.name,
12+
path: parsedPath.dir
13+
};
14+
},
1215

13-
// afterInstall: function(options) {
14-
// // Perform extra work here.
15-
// }
16+
fileMapTokens: function(options) {
17+
// Return custom template variables here.
18+
return {
19+
__name__: function(options) {
20+
return options.locals.name;
21+
},
22+
__path__: function(options) {
23+
return options.locals.path || 'components';
24+
}
25+
};
26+
}
1627
};

0 commit comments

Comments
 (0)