Last active
August 29, 2015 14:02
-
-
Save yoshuawuyts/cde9bd201e80312be4ff 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
#!/usr/bin/env node | |
/** | |
* Module dependencies | |
*/ | |
var spawn = require('child_process').spawn; | |
var program = require('commander'); | |
var fs = require('fs'); | |
/** | |
* Options. | |
*/ | |
program | |
.option('-p, --port <port>', 'specify the server port [1337]', '1337') | |
.option('-t, --task <task>', 'specify the build task [default]', 'default') | |
.option('-e, --environment <env>', 'specify the environment [development]', 'development'); | |
program.name = 'versity'; | |
/** | |
* Start 'versity'. | |
*/ | |
program | |
.command('start') | |
.description('start server') | |
.action(function() { | |
process.env.NODE_ENV = program.environment; | |
var args = ['--harmony', __dirname + '/../server/index/index.js'] | |
.concat(process.argv.slice(2)); | |
spawn(process.argv[0], args, { | |
env: process.env, | |
stdio: [0,1,2] | |
}); | |
}); | |
/** | |
* Build packages. | |
*/ | |
program | |
.command('build') | |
.description('build assets') | |
.action(function() { | |
process.env.NODE_ENV = program.environment; | |
var args = ['--harmony', __dirname + '/../node_modules/gulp/bin/gulp.js'] | |
.concat(program.task); | |
spawn(process.argv[0], args, { | |
env: process.env, | |
stdio: [0,1,2] | |
}); | |
}); | |
/** | |
* Parse arguments. | |
*/ | |
program.parse(process.argv); | |
/** | |
* Log help if no commands specified. | |
*/ | |
if (!process.argv[2]) { | |
program.help(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment