UNPKG

ember-legacy-class-transform

Version:
57 lines (48 loc) 1.71 kB
/* 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) }; } };