-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
85 lines (77 loc) · 1.66 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*eslint no-sync:0*/
'use strict';
var gulp = require('gulp'),
mocha = require('gulp-mocha'),
istanbul = require('gulp-istanbul'),
_ = require('lodash');
var fs = require('fs'),
path = require('path');
var IGNORE_ITEMS = ['node_modules', 'coverage', 'package.json'];
var topLevelPaths = (function getTopLevelPaths() {
var items = fs.readdirSync(__dirname)
.filter(function (entry) {
return entry[0] !== '.' && IGNORE_ITEMS.indexOf(entry) < 0;
})
.filter(function (entry) {
return fs.statSync(path.join(__dirname, entry)).isDirectory();
})
.join(',');
if (items !== '') {
return '{' + items + '}';
}
return '{_none_}'; // no subfolders to match
}());
var config = {
ignore : IGNORE_ITEMS,
coverage : {
statements : 80,
branches : 80,
functions : 80,
lines : 80
},
paths : {
js : [
'*.js',
topLevelPaths + '/**/*.js',
'!lib/logger.js',
'!*.spec.js',
'!**/*.spec.js'
],
tests : [
'test/**/*.spec.js'
],
whitespace : [
'*.*',
topLevelPaths + '/**/*.*',
'!deploy/**/*',
'!bin/**/*',
'!schema/**/*.yaml',
'!package.json',
'!proto/package.json',
'!**/*.bz2',
'!**/*.gz'
]
}
};
function onError(e) {
if (e.message) {
console.error(e.message);
}
if (e.stack) {
console.log(e.stack);
}
throw e;
}
gulp.task('mocha', function mochaTests(cb) {
gulp.src(config.paths.js)
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', function runTests() {
gulp.src(config.paths.tests)
.pipe(mocha({timeout:2000}))
.pipe(istanbul.writeReports())
.on('error', onError);
});
});
gulp.task('test', ['mocha']);
gulp.task('default', ['test']);