-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
77 lines (69 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
/* eslint-disable */
'use strict';
const $ = require('gulp-load-plugins')();
const sequence = require('run-sequence');
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([].concat(config.paths.src, config.paths.test))
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.if(config.eslint.failOnError, $.eslint.failAfterError()))
);
/**
* Runs unit tests and prints out
* a report.
*
* `gulp test:unit`
*/
gulp.task('test:unit', (cb) => {
process.env.NODE_ENV = 'test';
gulp.src(config.paths.src)
.pipe($.istanbul()) // Covering files
.pipe($.istanbul.hookRequire()) // Force `require` to return covered files
.on('finish', function () {
gulp.src(config.paths.test)
.pipe($.mocha(config.mocha))
.pipe($.istanbul.writeReports()) // Creating the reports after tests ran
.pipe($.istanbul.enforceThresholds({
thresholds: {
global: 80
}
})) // Enforce a coverage of at least 90%
.on('end', cb);
});
});
/**
* Runs both unit and end to end tests, sequentially.
*
* `gulp test`
*/
gulp.task('test', function (cb) {
sequence('test:unit', cb);
});
/**
* Watches sources and runs linter on
* changes.
*
* `gulp watch`
*/
gulp.task('watch', () => gulp.watch(config.paths.src, ['eslint']));
/**
* Lints source code and runs test suite.
* Used as a pre-commit hook.
*
* `gulp validate`
*/
gulp.task('validate', ['eslint', 'test:unit']);
/**
* Alias for 'validate'.
* Default task.
*/
gulp.task('default', ['validate']);