-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
61 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
59
60
61
'use strict';
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var stylish = require('jshint-stylish');
var paths = {
scripts: './lib/**/*.js',
tests: './test/**/*.js',
unit: './test/unit/*.js',
integration: './test/integration/*.js'
};
// common bits
function test(src){
return gulp.src(src, { read: false } )
.pipe(mocha({
timeout: 10000,
ignoreLeaks: false,
ui: 'bdd',
reporter: 'spec'
}).on('error', function(err){ console.log(err.message); }));
}
function lint(src){
return gulp.src(src)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish));
}
gulp.task('test', function() {
test([paths.unit]);
});
gulp.task('integration', function() {
test([paths.integration]);
});
gulp.task('lint', function () {
return lint([paths.scripts, paths.tests]);
});
gulp.task('watch', function () {
// watch and lint any files that are added or changed
gulp.watch([paths.scripts, paths.tests], function(event){
if(event.type !== 'deleted') {
lint([event.path]);
}
});
// run the unit tests when something changes
gulp.watch([paths.scripts, paths.unit], ['test']);
// run the integration tests when the integration tests change
gulp.watch([paths.integration], ['integration']);
});
gulp.task('default', ['watch']);