-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (54 loc) · 1.37 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
'use strict';
var gulp = require('gulp'),
istanbul = require('gulp-istanbul'),
jscs = require('gulp-jscs'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
scripts = ['**/*.js', '!node_modules/**', '!coverage/**'],
tests = 'test.js';
function lint(fail) {
return function() {
var l = gulp.src(scripts)
/* hint */
.pipe(jshint())
.pipe(jshint.reporter())
/* jscs */
.pipe(jscs());
if (fail) {
return l.pipe(jshint.reporter('fail'));
} else {
return l;
}
};
}
gulp.task('lint', lint(true));
gulp.task('lint-watch', lint(false));
gulp.task('watch:lint', function() {
gulp.watch(scripts, ['lint-watch']);
});
gulp.task('watch:test', function() {
gulp.watch(scripts, ['test']);
});
gulp.task('watch', function() {
gulp.watch(scripts, ['lint-watch', 'test']);
});
gulp.task('test', function() {
return gulp.src(tests)
.pipe(mocha({reporter: 'spec'}));
});
gulp.task('coverage', function (done) {
gulp.src(scripts.concat(['!' + tests]))
.pipe(istanbul())
.on('finish', function () {
/* tests */
gulp.src(tests)
.pipe(mocha({
reporter: 'dot'
}))
.pipe(istanbul.writeReports({
reporters: ['lcovonly', 'text-summary', 'html']
}))
.on('end', done);
});
});
gulp.task('default', ['lint', 'coverage']);