Created
January 12, 2015 09:22
-
-
Save yicone/1b47e79edf5b21d76f47 to your computer and use it in GitHub Desktop.
My first gulpfile
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
var gulp = require('gulp'); | |
var shell = require('gulp-shell'); | |
var preprocess = require('gulp-preprocess'); | |
var template = require('gulp-template'); | |
var os = require('os'); | |
var _ = require('underscore'); | |
//var replace = require('gulp-replace'); | |
//var inject = require('gulp-inject'); | |
gulp.task('redis', shell.task('redis-server > /dev/null &')) | |
var networkInterfaces = (os.networkInterfaces().eth0 || os.networkInterfaces().en0); | |
var local_ip = _.where(networkInterfaces, {"family": "IPv4"})[0].address; | |
console.log('local ip', local_ip); | |
var env = process.env.NODE_ENV || 'development'; | |
var config = { | |
weinre_host: local_ip + ':8080', | |
use_weinre: true | |
} | |
gulp.task('weinre', shell.task('weinre --boundHost -all- -v ')) | |
gulp.task('config', function () { | |
gulp.src('public/src/index.html') | |
.pipe(template({weinre_host: config.weinre_host})) | |
.pipe(preprocess({context: {NODE_ENV: env, DEBUG: true}})) | |
.pipe(gulp.dest('public/disc')) | |
}) | |
gulp.task('dev_run', | |
shell.task('node server.js --name="payment-sdk-server" --watch') | |
) | |
gulp.task('run', | |
shell.task('pm2 startOrRestart processes.json --name="payment-sdk-server" --watch') | |
) | |
gulp.task('dev_env', ['redis', 'weinre', 'config', 'dev_run']) | |
gulp.task('test_env', ['redis', 'weinre', 'config', 'run']) | |
gulp.task('prod_env', ['redis', 'config', 'run']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment