-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
92 lines (77 loc) · 2.03 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
"use strict";
const gulp = require('gulp');
const babel = require('gulp-babel');
const jshint = require('gulp-jshint');
const mocha = require('gulp-mocha');
const istanbul = require('gulp-istanbul');
const util = require('gulp-util');
/**
* Main build task
*/
gulp.task('build', function () {
gulp.src('./src/**/*.js')
.pipe(babel({
presets: ["es2015"]
}))
.pipe(gulp.dest('./bin'));
});
/**
* JS lint task
*/
gulp.task('lint', function() {
return gulp.src('./src/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
/**
* Initiates code coverage task
*/
gulp.task('istanbul', function () {
return gulp.src('./src/**/*.js')
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
/**
* A task to run app tests
*/
gulp.task('tests', ['istanbul'], function() {
return gulp.src(['./test/init.js', './test/tests/**/*.test.js'])
.pipe(mocha({
timeout: 10000
}))
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({
thresholds: {
global: {
statements : 90,
branches : 90,
functions : 90,
lines : 90
}
}
}))
.once('error', (err) => {
util.log(err);
process.exit(1);
});
});
/**************************************************************************************
Main Gulp Tasks
***************************************************************************************/
/**
* The default task (called when you run `gulp` from cli)
* It lints code and builds required libs
*/
gulp.task('default', ['lint', 'tests', 'build'], function (done) {
console.log('Build successfully finished');
done();
});
/**
*
*/
gulp.task('test', ['lint', 'tests'], function (done) {
console.log('Tests successfully finished');
done();
});