-
Notifications
You must be signed in to change notification settings - Fork 7
Description
i want to create a 'complex' service (like the complex directive template) but the difference is that i want it to have a .command suffix instead of the .service suffix while creating a 'command' type service.
what happens now is the generator creates the files still with the .service suffix and omits the file name all together...
here's my code for the service index.js:
`
'use strict';
var util = require('util');
var yeoman = require('yeoman-generator');
var path = require('path');
var cgUtils = require('../utils.js');
var chalk = require('chalk');
var _ = require('underscore');
var fs = require('fs');
_.str = require('underscore.string');
.mixin(.str.exports());
var ServiceGenerator = module.exports = function ServiceGenerator(args, options, config) {
cgUtils.getNameArg(this, args);
yeoman.generators.Base.apply(this, arguments);
};
util.inherits(ServiceGenerator, yeoman.generators.Base);
ServiceGenerator.prototype.askFor = function askFor() {
var cb = this.async();
var prompts = [{
type: 'confirm',
name: 'isCommand',
message: 'Will this service act as a command?',
default: false
}];
cgUtils.addNamePrompt(this, prompts, 'service');
this.prompt(prompts, function(props) {
if (props.name) {
this.name = props.name;
}
this.isCommand = props.isCommand;
cgUtils.askForModuleAndDir('service', this, false, cb); //Tapas: no need to ask for own directory(this.isCommand)
}.bind(this));
};
ServiceGenerator.prototype.files = function files() {
var configName = 'serviceSimpleTemplates';
var defaultDir = 'templates/simple';
var suffix = 'service';
if (this.isCommand) {
configName = 'commandComplexTemplates';
defaultDir = 'templates/complex';
suffix = 'command';
}
this.htmlPath = path.join(this.dir, this.name + '.service.html').replace(/\\/g, '/');
this.htmlPath = this.htmlPath.replace('app/', '');
cgUtils.processTemplates(this.name, this.dir, suffix, this, defaultDir, configName, this.module);
};
`
any suggestions will be most welcome!