-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
81 lines (73 loc) · 1.64 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
'use strict';
const $ = require('gulp-load-plugins')();
const config = require('./build.json');
const gulp = require('gulp');
// Declare release task
$.release.register(gulp);
/**
* Runs eslint linter on source code
* and prints a report.
*
* `gulp eslint`
*/
gulp.task('eslint', () =>
gulp.src(config.paths.src)
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.if(config.eslint.failOnError, $.eslint.failAfterError()))
);
/**
* Watches sources and runs linter on
* changes.
*
* `gulp watch`
*/
gulp.task('watch', () => gulp.watch(config.paths.src, ['validate']));
/**
* Runs unit tests and writes out
* a report.
*
* `gulp test`
*/
gulp.task('test', () => {
process.env.NODE_ENV = 'test';
process.env.LOGGER_LEVEL = 'error';
return gulp.src(config.paths.src)
// Covering files
.pipe($.istanbul())
// Force `require` to return covered files
.pipe($.istanbul.hookRequire())
.on('finish', function() {
gulp.src(config.paths.test, {
read: false
})
.pipe($.mocha(config.mocha))
// Creating the reports after tests ran
.pipe($.istanbul.writeReports())
.pipe($.if(config.istanbul.enforceThresholds,
$.istanbul.enforceThresholds(config.istanbul)))
.pipe($.exit());
});
});
/**
* Lints source code and runs test suite.
* Used as a pre-commit hook.
*
* `gulp validate`
*/
gulp.task('validate', ['eslint', 'test']);
/**
* Uploads coverage report to codecov.io
*
* `gulp coverage`
*/
gulp.task('coverage', () => {
return gulp.src(config.codecov.src)
.pipe($.codecov());
});
/**
* Runs 'validate'.
*
* `gulp`
*/
gulp.task('default', ['validate']);