-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
66 lines (52 loc) · 1.48 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var gulp = require('gulp'),
nodemon = require('gulp-nodemon'),
gutil = require('gulp-util'),
spawn = require('gulp-spawn-shim'),
debug = require('gulp-debug'),
through = require('through2'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify');
var paths = {
server: '/server'
};
var trim = function(buf) {
return buf.toString('utf8', 0, 1000).trim() + '...\n';
};
gulp.task('mongo', function(cb) {
var options = {
cmd: 'mongod',
args: [],
silent: false
};
return gulp.src('server.js')
.pipe(spawn(options))
.pipe(through.obj(function(chunk, enc, callback) {
gutil.log(trim(chunk.contents));
callback();
}));
});
gulp.task('redis', function() {
var options = {
cmd: 'redis-server',
args: [],
silent: false
};
return gulp.src('server.js')
.pipe(spawn(options))
.pipe(through.obj(function(chunk, enc, callback) {
gutil.log(trim(chunk.contents));
callback();
}));
});
gulp.task('startNode', ['mongo', 'redis'], function() {
return nodemon({ script: 'server.js', options: '-i app' });
// .on('restart', ['lint'])
});
gulp.task('startNodeDebug', ['mongo', 'redis'], function() {
return nodemon({ script: 'server.js', options: '-i app --debug-brk' });
// .on('restart', ['lint'])
});
gulp.task('server', ['mongo', 'redis', 'startNode']);
gulp.task('debug', ['mongo', 'redis', 'startNodeDebug']);
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['server']);