UNPKG

generator-levi-9-angularjs-2

Version:

Yeoman generator for levi9 angularjs2 projects

44 lines (36 loc) 1.2 kB
'use strict'; var yeoman = require('yeoman-generator'); var _ = require('lodash'); var pathPrefix = 'src/app/'; var generatorUtils = require('../generatorUtils'); module.exports = yeoman.Base.extend({ constructor: function () { yeoman.Base.apply(this, arguments); this.argument('pipeName', { 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.pipeNameCamel = _.camelCase(this.pipeName); this.pipeNameClass = _.upperFirst(this.pipeNameCamel); }, writing: function () { if (generatorUtils.invalidInput('class', this.pipeName, this.path)) { return; } this.path = generatorUtils.addPrefixAndSuffixToPath(pathPrefix, this.path, '/'); this.fs.copyTpl( this.templatePath('_pipe.ts'), this.destinationPath(this.path + this.pipeName + '.pipe.ts'), { name: this.pipeNameCamel, nameClass: this.pipeNameClass }); } });