-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathindex.js
66 lines (55 loc) · 1.74 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint-env node */
var stringUtil = require('ember-cli-string-utils');
var path = require('path');
var inflector = require('inflection');
module.exports = {
description: 'Generates import wrappers for a route and its template.',
fileMapTokens: function() {
return {
__templatepath__: function(options) {
if (options.pod) {
return path.join(options.podPath, options.dasherizedModuleName);
}
return 'templates';
},
__templatename__: function(options) {
if (options.pod) {
return 'template';
}
return options.dasherizedModuleName;
},
__name__: function (options) {
if (options.pod) {
return 'route';
}
return options.dasherizedModuleName;
},
__path__: function(options) {
if (options.pod && options.hasPathToken) {
return path.join(options.podPath, options.dasherizedModuleName);
}
return 'routes';
},
__root__: function(options) {
if (options.inRepoAddon) {
return path.join('lib', options.inRepoAddon, 'app');
}
return 'app';
}
};
},
locals: function (options) {
var locals = {};
var addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name();
var addonName = stringUtil.dasherize(addonRawName);
var fileName = stringUtil.dasherize(options.entity.name);
['route', 'template'].forEach(function (blueprint) {
var pathName = [addonName, inflector.pluralize(blueprint), fileName].join('/');
if (options.pod) {
pathName = [addonName, fileName, blueprint].join('/');
}
locals[blueprint + 'ModulePath'] = pathName;
});
return locals;
}
};