forked from keithmorris/node-dotenv-extended
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
82 lines (73 loc) · 2.11 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
/**
* Created by Keith Morris on 2/9/16.
*/
var
babel = require('gulp-babel'),
del = require('del'),
eslint = require('gulp-eslint'),
gulp = require('gulp'),
istanbul = require('gulp-istanbul'),
mocha = require('gulp-mocha'),
runSequence = require('run-sequence')
;
var options = {
buildDir: 'lib'
};
gulp.task('clean', [], function () {
return del([
options.buildDir,
'coverage'
]);
});
gulp.task('watch', [], function () {
gulp.watch(['src/**/*.js'], ['build']);
});
gulp.task('lint', [], function () {
return gulp.src(['src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('mocha', [], function () {
var old_cwd = process.cwd();
process.chdir('test');
return gulp.src(['**/*.spec.js'])
.pipe(mocha())
.on('end', function () {
process.chdir(old_cwd);
});
});
gulp.task('unittest', ['build'], function (callback) {
gulp.src([
'lib/**/*.js'
])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on('finish', function () {
var old_cwd = process.cwd();
process.chdir('test');
gulp.src([
'**/*.spec.js'
])
.pipe(mocha())
.pipe(istanbul.writeReports({
dir: '../coverage',
reporters: ['text-summary', 'lcovonly']
})) // Creating the reports after tests ran
.pipe(istanbul.enforceThresholds({ thresholds: { global: 80 } })) // Enforce a coverage of at least 80%
.on('end', function () {
process.chdir(old_cwd);
callback();
});
});
});
gulp.task('babel', [], function () {
return gulp.src([
'src/**/*.js'
])
.pipe(babel())
.pipe(gulp.dest(options.buildDir));
});
gulp.task('build', [], function (callback) {
runSequence('clean', 'lint', 'babel', callback);
});