-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
103 lines (90 loc) · 2.7 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
101
102
103
'use strict';
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')();
const del = require('del');
const TESTS = [
'test-dist/test/test-ravel-steam-auth-provider.js',
'test-dist/test/test-integration.js'
];
gulp.task('lint', function () {
return gulp.src(['./lib/**/*.js', './test/**/*.js', 'gulpfile.js'])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
});
gulp.task('watch', ['lint'], function () {
gulp.watch(['./lib/**/*.js'], ['lint']);
gulp.watch(['gulpfile.js', './test/**/*.js'], ['lint']);
});
gulp.task('clean', function () {
return del([
'reports', 'docs', 'test-dist'
]);
});
gulp.task('cover-lib', ['transpile-lib'], function () {
return gulp.src(['./test-dist/lib/**/*.js'])
.pipe(plugins.istanbul({
// instrumenter: isparta.Instrumenter,
includeUntested: true
}))
.pipe(plugins.istanbul.hookRequire());
});
gulp.task('copy-lib', ['clean', 'lint'], function () {
return gulp.src('lib/**/*.js')
.pipe(gulp.dest('test-dist/lib'));
});
gulp.task('transpile-lib', ['clean', 'lint'], function () {
return gulp.src('lib/**/*.js')
.pipe(plugins.sourcemaps.init())
.pipe(plugins.babel())
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('test-dist/lib'));
});
gulp.task('transpile-tests', ['clean', 'lint'], function () {
return gulp.src('test/**/*.js')
.pipe(plugins.sourcemaps.init())
.pipe(plugins.babel())
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('test-dist/test'));
});
// necessary to locate issues in code, due to https://github.com/gotwarlost/istanbul/issues/274
gulp.task('test-no-cov', ['copy-lib', 'transpile-tests'], function () {
const env = plugins.env.set({
LOG_LEVEL: 'critical'
});
return gulp.src(TESTS)
.pipe(env)
.pipe(plugins.mocha({
reporter: 'spec',
quiet: false,
colors: true,
timeout: 10000
}))
.pipe(env.reset);
});
gulp.task('test', ['cover-lib', 'transpile-tests'], function () {
const env = plugins.env.set({
LOG_LEVEL: 'critical'
});
return gulp.src(TESTS)
.pipe(env)
.pipe(plugins.mocha({
reporter: 'spec',
quiet: false,
colors: true,
timeout: 60000
}))
// Creating the reports after tests ran
.pipe(plugins.istanbul.writeReports({
dir: './reports',
reporters: ['lcov', 'json', 'text', 'text-summary', 'html']
}))
// Enforce a coverage of at least 100%
// .pipe(plugins.istanbul.enforceThresholds({ thresholds: { global: 100 } }))
.pipe(env.reset);
});
gulp.task('show-coverage', function () {
return gulp.src('./reports/index.html')
.pipe(plugins.open());
});
gulp.task('default', ['watch']);