Forked from anonymous/generators.generator-bot.app.index.js
Last active
August 29, 2015 13:55
-
-
Save ratbeard/8701259 to your computer and use it in GitHub Desktop.
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
module.exports = (generate) -> | |
{register, copy, mkdir, set, camelcase} = generate | |
# Register all generators in 1 file | |
# Templates are run through a <%= %> | |
# args are automatically 'set' and available inside templates | |
# extend string prototype w/ handy helpers | |
# need a --dry-run options | |
register(name: "bot", args: "<name>", run: (args) -> | |
mkdir("src/bots/<%= name.camelcase %>") | |
copy("./api.coffee.template", "src/bots/<%= name.camelcase %>/") | |
copy("./bot.coffee.template", "src/bots/<%= name.camelcase %>/") | |
) | |
} |
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
Why I don't like yeoman:
npm link
'ed locally to use (adding extra step)