Created
March 9, 2012 20:51
-
-
Save k33g/2008635 to your computer and use it in GitHub Desktop.
generate express app with gimme
This file contains 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 = mystack_cmd; | |
var fs = require('fs') | |
, path = require('path') | |
, exec = require('child_process').exec; | |
mystack_cmd.usage = "gimme mystack <appname>"; | |
mystack_cmd.description = ['my personnal express.js boilerplate', "@k33g_org"]; | |
function launch(cmd, cb) { | |
exec(cmd, function(err, stdout, stderr) { | |
if (err) { | |
console.log(err); | |
throw err; | |
} | |
else { | |
console.log(cmd+ " -> OK"); | |
if(cb) cb(); | |
} | |
}); | |
} | |
function mystack_cmd (opts, cb) { | |
var appname = opts.argv.remain.slice(1)[0]; | |
launch("express " + appname, function() { | |
launch("cd " + appname + " && npm install -d", function(){ | |
launch("cd " + appname + " && npm install ejs", function() { | |
console.log(appname + " has been created.") | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment