forked from scravy/white-horse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
68 lines (56 loc) · 1.59 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
64
65
66
/* vim: set et sw=2 ts=2: */
'use strict';
var thresholds = {
statements: 0,
branches: 0,
functions: 0,
lines: 0
};
var chalk = require('chalk'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
istanbul = require('gulp-istanbul'),
enforcer = require('gulp-istanbul-enforcer'),
gulp = require('gulp');
var npmPackage = require('./package.json');
function errorHandler(err) {
console.log(chalk.red(err.message));
process.exit(1);
}
var sources = [ 'index.js', 'Module.js', 'WhiteHorse.js', 'Options.js', 'lib/**/*.js' ];
gulp.task('lint', function (done) {
gulp.src([ '*.js', 'lib/**/*.js', 'test/*.js' ])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'))
.on('error', errorHandler)
.on('finish', done);
});
gulp.task('coverage', [ 'lint' ], function (done) {
gulp.src(sources)
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('error', errorHandler)
.on('finish', function () {
gulp.src('test/*.js')
.pipe(mocha())
.pipe(istanbul.writeReports({ dir: 'dist/coverage/' }))
.on('finish', done);
});
});
gulp.task('test', [ 'lint' ], function (done) {
gulp.src('test/*.js')
.pipe(mocha())
.on('finish', done);
});
gulp.task('check', [ 'coverage' ], function (done) {
gulp.src('.')
.pipe(enforcer({
thresholds: thresholds,
coverageDirectory: 'dist/coverage/',
rootDirectory: ''
}))
.on('error', errorHandler)
.on('finish', done);
});
gulp.task('default', [ 'check' ]);