1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| 'use strict';
var generators = require('yeoman-generator'), path = require('path');
module.exports = generators.Base.extend({
constructor: function(){ generators.Base.apply(this, arguments); this.argument('controllerPath', { type: String, required: true }); },
setup: function(){ this.controllerName = this.controllerPath.split('/').pop(); this.localPath = this.controllerPath.split('/').join(path.sep); this.config.save(); },
performCopy: function(){ var controllerDestination = ['app', 'controllers', this.localPath].join(path.sep), controllerOutput = [controllerDestination, this.controllerName + '.js'].join(path.sep), context = { controllerName: this.controllerName };
this.template('controller.js', controllerOutput, context); } });
|