-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
52 lines (46 loc) · 1.11 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
const gulp = require('gulp');
const $ = require('gulp-load-plugins')({ lazy: true });
const supertest = require('supertest');
gulp.task('serve', () => {
$.nodemon({
script: 'app.js',
ext: 'js',
env: {
PORT: 3000
},
ignore: ['./node_modules/**', 'gulpfile.js']
})
.on('restart', () => {
log('Restarting');
});
});
gulp.task('check-js-styles', () => {
return gulp.src(['**/*.js', '!node_modules/**'])
.pipe($.jscs())
.pipe($.jscs.reporter())
.pipe($.jscs.reporter('fail'))
.pipe(gulp.dest('.'));
});
gulp.task('test', () => {
$.env({ vars: { ENV: 'Test' } });
return gulp.src('tests/*.js', { read: false })
.pipe($.mocha({ reporter: 'nyan' }))
.once('error', () => {
process.exit(1);
})
.once('end', () => {
process.exit();
});
});
gulp.task('default', ['check-js-styles', 'serve']);
function log(msg) {
if (typeof (msg) === 'object') {
for (const item in msg) {
if (msg.hasOwnProperty(item)) {
$.util.log($.util.colors.blue(msg[item]));
}
}
} else {
$.util.log($.util.colors.blue(msg));
}
}