UNPKG

generator-levi-9-angularjs-2

Version:

Yeoman generator for levi9 angularjs2 projects

54 lines (48 loc) 1.75 kB
'use strict'; var yeoman = require('yeoman-generator'); var generatorUtils = require('../generatorUtils'); var _ = require('lodash'); var pathPrefix = require('../config').paths.app; module.exports = yeoman.Base.extend({ constructor: function () { yeoman.Base.apply(this, arguments); this.argument('mod', { type: String, required: true, desc: 'It will be used for folder name, name of service, components and \'class\'' + 'Use kebab-case, camelCase or snake_case' }); this.argument('path', { type: String, defaults: '', desc: 'Supports paths relative to /$root/src/app/$entity, defaults to /$root/src/app/$entity' }); this.moduleNameClass = _.upperFirst(_.camelCase(this.mod)); }, initializing: function () { this.composeWith('levi-9-angularjs-2:component', { arguments: [this.mod, generatorUtils.addPrefixToPath(this.path, this.mod)] }, { local: require.resolve('../component') }); this.composeWith('levi-9-angularjs-2:service', { arguments: [this.mod, generatorUtils.addPrefixToPath(this.path, this.mod)] }, { local: require.resolve('../service') }); this.composeWith('levi-9-angularjs-2:class', { arguments: [this.mod, generatorUtils.addPrefixToPath(this.path, this.mod)] }, { local: require.resolve('../class') }); }, writing: function () { this.fs.copyTpl( this.templatePath('_module.ts'), this.destinationPath(generatorUtils.addPrefixAndSuffixToPath(pathPrefix, this.path, this.mod + '/') + this.mod + '.module.ts'), {name: this.mod, className: this.moduleNameClass} ); } });