This repository was archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
53 lines (46 loc) · 1.49 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
'use strict';
const path = require('path');
const stringUtil = require('ember-cli-string-utils');
const getPathOption = require('ember-cli-get-component-path-option');
const normalizeEntityName = require('ember-cli-normalize-entity-name');
module.exports = {
description: 'Generates a component class.',
fileMapTokens: function () {
return {
__path__: function (options) {
if (options.pod) {
return path.join(options.podPath, options.locals.path, options.dasherizedModuleName);
}
return 'components';
},
__name__: function (options) {
if (options.pod) {
return 'component';
}
return options.dasherizedModuleName;
},
__root__: function (options) {
if (options.inRepoAddon) {
return path.join('lib', options.inRepoAddon, 'app');
}
return 'app';
},
};
},
normalizeEntityName: function (entityName) {
return normalizeEntityName(entityName);
},
locals: function (options) {
let addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name();
let addonName = stringUtil.dasherize(addonRawName);
let fileName = stringUtil.dasherize(options.entity.name);
let importPathName = [addonName, 'components', fileName].join('/');
if (options.pod) {
importPathName = [addonName, 'components', fileName, 'component'].join('/');
}
return {
modulePath: importPathName,
path: getPathOption(options),
};
},
};