-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
100 lines (84 loc) · 1.81 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const gulp = require('gulp');
const $ = require('gulp-load-plugins')();
// ## //
// Configuration
var config = {
reports: process.env.CIRCLE_TEST_REPORTS || 'reports'
};
// Log errors
var _logErrors = function (err) {
$.util.log(
$.util.colors.red(err)
);
process.exit(1);
};
gulp.task('eslint', function () {
return gulp
.src([
'gulpfile.js',
'index.js',
'lib/**/*.js',
'test/**/*.js'
])
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
gulp.task('mocha', function () {
return gulp
.src([
'test/*.test.js'
], {
read: false
})
.pipe($.mocha({
timeout: 5000,
reporter: 'spec',
require: [
'./test/bootstrap/node'
]
}));
});
gulp.task('pre-cover', function () {
return gulp
.src([
'index.js',
'lib/**/*.js'
])
.pipe($.istanbul({
includeUntested: true
}))
.pipe($.istanbul.hookRequire());
});
gulp.task('cover', ['pre-cover'], function () {
process.env.XUNIT_FILE = config.reports + '/xunit.xml';
return gulp
.src([
'test/*.test.js'
], {
read: false
})
.pipe($.mocha({
timeout: 5000,
reporter: require('xunit-file'),
require: [
'./test/bootstrap/node'
]
}))
.on('error', _logErrors)
.pipe($.istanbul.writeReports({
reporters: ['lcov', 'text-summary']
}));
});
// ## //
gulp.task('default', [
'test'
]);
gulp.task('test', [
'eslint',
'mocha'
]);
gulp.task('test:ci', [
'eslint',
'cover'
]);