forked from keystonejs/keystone-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (48 loc) · 1.32 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
watch = require('gulp-watch'),
// changed = require('gulp-changed'),
mocha = require('gulp-mocha'),
colors = require('colors');
/*
* Create variables for our project paths so we can change in one place
*/
var paths = {
'src':['./lib/**/*.js','./routes/**/*.js'],
'tests':['./test/*.js', './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(){
gulp.src(paths.tests)
.pipe(mocha({reporter: 'dot'}))
.on('error', handleError);
});
// gulp for running the mocha tests with spec reporter
gulp.task('spec', function(){
gulp.src(paths.tests)
.pipe(mocha({reporter: 'spec'}))
.on('error', handleError);
});
/*
* auto/watch gulp tasks that will trigger the tests on
* file changes
*/
gulp.task('autotest', function(){
gulp.watch(paths.src.concat(paths.tests), ['test']);
});
gulp.task('autospec', function(){
gulp.watch(paths.src.concat(paths.tests), ['spec']);
});