-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
53 lines (45 loc) · 1.09 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
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var del = require('del');
var coveralls = require('gulp-coveralls');
var istanbul = require('gulp-istanbul');
var watching = false;
function onError(err) {
if(watching) {
this.emit('end');
}
else {
console.log(err.toString());
process.exit(1);
}
}
gulp.task ('test',['clean'],function(cb) {
gulp.src('index.js')
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(['test.js'])
.pipe(mocha({reporter:"spec"}))
.pipe(istanbul.writeReports())
.on('end', cb)
.on('error',onError);
})
.on('error',onError);
});
// gulp.task('test-report', function() {
// return gulp.src(['test.js'])
// .pipe(mocha({reporter:"doc"}))
// .pipe(gulp.dest('test-report'));
// });
gulp.task('clean', function (cb) {
del(".coverdata", cb);
});
gulp.task('coveralls',['test'], function() {
return gulp.src('coverage/lcov.info')
.pipe(coveralls());
});
gulp.task('watch', function() {
watching=true;
gulp.watch('*.js', ['test']);
});
gulp.task('default', ['coveralls']);