generator-levi-9-angularjs-2
Version:
Yeoman generator for levi9 angularjs2 projects
48 lines (43 loc) • 1.52 kB
JavaScript
'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('serviceName',
{
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.serviceNameCamel = _.camelCase(this.serviceName);
this.serviceNameClass = _.upperFirst(this.serviceNameCamel);
},
writing: function () {
if (generatorUtils.invalidInput('service', this.serviceName, this.path)) {
return;
}
this.path = generatorUtils.addPrefixAndSuffixToPath(pathPrefix, this.path, '/');
this.fs.copyTpl(
this.templatePath('_service.ts'),
this.destinationPath(this.path + this.serviceName + '.service.ts'), {
name: this.serviceName,
nameClass: this.serviceNameClass
});
this.fs.copyTpl(
this.templatePath('_service.spec.ts'),
this.destinationPath(this.path + this.serviceName + '.service.spec.ts'), {
name: this.serviceName,
nameClass: this.serviceNameClass,
nameCamel: this.serviceNameCamel
});
}
});