forked from hexojs/hexo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
48 lines (38 loc) · 1020 Bytes
/
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
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var lib = 'lib/**/*.js';
var test = 'test/scripts/**/*.js';
gulp.task('coverage', function(){
return gulp.src(lib)
.pipe($.istanbul())
.pipe($.istanbul.hookRequire());
});
gulp.task('coverage:clean', function(callback){
del(['coverage/**/*'], callback);
});
function mochaStream(){
return gulp.src('test/index.js', {read: false})
.pipe($.mocha({
reporter: 'spec'
}));
}
gulp.task('mocha', ['coverage'], function(){
return mochaStream()
.pipe($.istanbul.writeReports());
});
gulp.task('mocha:nocov', function(){
return mochaStream();
});
gulp.task('jshint', function(){
return gulp.src(lib)
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.jshint.reporter('fail'));
});
gulp.task('watch', function(){
gulp.watch(lib, ['mocha', 'jshint']);
gulp.watch(['test/**/*.js', test], ['mocha']);
});
gulp.task('test', ['mocha', 'jshint']);