UNPKG

generator-levi-9-angularjs-2

Version:

Yeoman generator for levi9 angularjs2 projects

42 lines (34 loc) 1.14 kB
'use strict'; var yeoman = require('yeoman-generator'); var _ = require('lodash'); var pathPrefix = require('../config').paths.app; var generatorUtils = require('../generatorUtils'); module.exports = yeoman.Base.extend({ constructor: function () { yeoman.Base.apply(this, arguments); this.argument('className', { type: String, required: true, desc: 'Use kebab-case, camelCase or snake_case' }); this.argument('path', { type: String, defaults: pathPrefix, desc: 'Supports paths relative to /$root/src/app, defaults to \'' + pathPrefix + '\'' }); this.classNameClass = _.upperFirst(_.camelCase(this.className)); }, writing: function () { if (generatorUtils.invalidInput('class', this.className, this.path)) { return; } this.path = generatorUtils.addPrefixAndSuffixToPath(pathPrefix, this.path, '/'); this.fs.copyTpl( this.templatePath('_class.ts'), this.destinationPath(this.path + this.className + '.ts'), { name: this.classNameClass }); } });