-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
64 lines (56 loc) · 1.75 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
watch = require('gulp-watch'),
// changed = require('gulp-changed'),
mocha = require('gulp-mocha'),
istanbul = require('gulp-istanbul'),
colors = require('colors'),
coveralls = require('gulp-coveralls');
var paths = {
'src': ['./sitemark.js', './lib/**/*.js', './routes/**/*.js'],
'tests': ['./test/**/*.js']
};
// An error handler for the tests during gulp-watch
// Otherwise the gulp-watch will terminate
var handleError = function(err) {
console.log((err.name + ': ' + err.plugin + ' - ' + err.message).red);
// propogate
return;
};
// gulp lint
gulp.task('lint', function() {
gulp.src(paths.src)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// gulp for running the mocha tests with default dot reporter
gulp.task('test', function(cb) {
gulp.src(paths.src)
.pipe(istanbul())
.on('finish', function() {
gulp.src(paths.tests)
.pipe(mocha({
require: 'should',
reporter: 'spec'
}))
.pipe(istanbul.writeReports({
reporters: ['lcov', 'html', 'text-summary']
}))
.on('end', function() {
if (process.env.COVERALLS_REPO_TOKEN) {
gulp.src('coverage/**/lcov.info')
.pipe(coveralls())
.on('end', cb);
}
})
.on('error', handleError);
});
});
/*
* auto/watch gulp tasks that will trigger the tests on
* file changes
*/
gulp.task('watch', function() {
gulp.watch(paths.src.concat(paths.tests), ['lint', 'test']);
});
gulp.task('default', ['lint', 'test']);