-
Notifications
You must be signed in to change notification settings - Fork 21
/
gulpfile.js
79 lines (66 loc) · 2.39 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var nodemon = require('gulp-nodemon');
var mocha = require('gulp-mocha');
var eslint = require('gulp-eslint');
var util = require('gulp-util');
const {dumpError} = require('wriocommon').utils;
function restart_nodemon () {
if (nodemon_instance) {
console.log("Restarting nodemon");
nodemon_instance.emit('restart');
} else {
console.log("Nodemon isntance not ready yet")
}
}
gulp.task('test', function() {
var grepStatement = util.env.grep ? {grep:util.env.grep} : {};
return gulp.src('test/**/*.js', {read: false})
// gulp-mocha needs filepaths so you can't have any plugins before it
.pipe(mocha(Object.assign({
reporter: 'dot',
timeout: 60000,
},grepStatement)))
.once('error', function (err) {
dumpError(err);
process.exit(1);
})
.once('end', function () {
process.exit();
});
});
gulp.task('lint', function () {
// ESLint ignores files with "node_modules" paths.
// So, it's best to have gulp ignore the directory as well.
// Also, Be sure to return the stream from the task;
// Otherwise, the task may end before the stream has finished.
return gulp.src(['./src/**/*.js*','!./src/client/js/3rdparty/*.js*'])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
});
var nodemon_instance;
gulp.task('nodemon', function() {
if (!nodemon_instance) {
nodemon_instance = nodemon({
script: 'server.js',
watch: 'src/__manual_watch__',
ext: '__manual_watch__',
verbose: false,
}).on('restart', function() {
console.log('~~~ restart server ~~~');
});
} else {
nodemon_instance.emit('restart');
}
});
gulp.task('default', []);
gulp.task('watch', ['default', 'nodemon'], function() {
gulp.watch(['src/server/**/*.*'],restart_nodemon);
});