-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgulpfile.js
46 lines (38 loc) · 1.08 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
var gulp = require('gulp');
var connect = require('gulp-connect');
var mocha = require('gulp-mocha');
var eslint = require('gulp-eslint');
var files = ['index.js', 'gulpfile.js'];
gulp.task('lint', function () {
return gulp.src(files).pipe(eslint()).pipe(eslint.format());
// .pipe(eslint.failAfterError());
});
gulp.task('test', function () {
var startServer = gulp.task('start-server');
startServer();
return gulp
.src('test/*.js', { read: false })
.pipe(mocha({ timeout: 5000 }))
.on('end', connect.serverClose);
});
gulp.task('test:w', function () {
var startServer = gulp.task('start-server');
startServer();
return gulp
.src('test/*.js', { read: false })
.pipe(mocha({ timeout: 5000, watch: true }))
.on('end', connect.serverClose);
});
gulp.task('default', gulp.series(['lint', 'test']));
gulp.task('watch', function () {
gulp.watch(files, gulp.series(['lint', 'test']));
});
gulp.task('start-server', function () {
connect.server({
root: './test',
port: 1234,
});
});
gulp.task('close-server', function () {
connect.serverClose();
});