Created
January 30, 2014 02:00
-
-
Save anonymous/8701255 to your computer and use it in GitHub Desktop.
Yeoman has a bad api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var util = require('util'); | |
var path = require('path'); | |
var yeoman = require('yeoman-generator'); | |
var botname = null | |
var BotGenerator = module.exports = function BotGenerator(args, options, config) { | |
botname = args[0] | |
yeoman.generators.Base.apply(this, arguments); | |
}; | |
util.inherits(BotGenerator, yeoman.generators.Base); | |
BotGenerator.prototype.askFor = function askFor() { | |
var cb = this.async(); | |
var prompts = [{ | |
name: 'bot', | |
message: 'Bot name?', | |
default: 'newbot' | |
}]; | |
if (botname) prompts.shift() | |
this.prompt(prompts, function (props) { | |
this.bot = botname || props.bot; | |
this.botClass = this.bot[0].toUpperCase() + this.bot.slice(1); | |
cb(); | |
}.bind(this)); | |
}; | |
BotGenerator.prototype.app = function app() { | |
path = 'src/bots/' + this.bot + '/' | |
this.mkdir(path); | |
this.template("api.coffee", path + 'api.coffee') | |
this.template("bot.coffee", path + 'bot.coffee') | |
}; | |
BotGenerator.prototype.projectfiles = function projectfiles() { | |
//this.copy('editorconfig', '.editorconfig'); | |
//this.copy('jshintrc', '.jshintrc'); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment