/* eslint-env node */
var stringUtil = require('ember-cli-string-utils');
var validComponentName = require('ember-cli-valid-component-name');
var getPathOption = require('ember-cli-get-component-path-option');
var path = require('path');
var normalizeEntityName = require('ember-cli-normalize-entity-name');
module.exports = {
description: 'Generates a component. Name must contain a hyphen.',
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) {
entityName = normalizeEntityName(entityName);
return validComponentName(entityName);
},
locals: function(options) {
var addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name();
var addonName = stringUtil.dasherize(addonRawName);
var fileName = stringUtil.dasherize(options.entity.name);
var importPathName = [addonName, 'components', fileName].join('/');
if (options.pod) {
importPathName = [addonName, 'components', fileName, 'component'].join('/');
}
return {
modulePath: importPathName,
path: getPathOption(options)
};
}
};
# |
Change |
User |
Description |
Committed |
|
#1
|
23539 |
jenbottom |
Adding the basic code for ember test appk, created with 'ember new' command |
|
|