UNPKG

generator-levi-9-angularjs-2

Version:

Yeoman generator for levi9 angularjs2 projects

42 lines (34 loc) 1.15 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('interfaceName', { 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.interfaceNameClass = _.upperFirst(_.camelCase(this.interfaceName)); }, writing: function () { if (generatorUtils.invalidInput('class', this.interfaceName, this.path)) { return; } this.path = generatorUtils.addPrefixAndSuffixToPath(pathPrefix, this.path, '/'); this.fs.copyTpl( this.templatePath('_interface.ts'), this.destinationPath(this.path + this.interfaceName + '.interface.ts'), { name: this.interfaceNameClass }); } });