-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.babel.js
143 lines (117 loc) · 3.3 KB
/
gulpfile.babel.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import Config from 'configstore';
import babel from 'gulp-babel';
import cache from 'gulp-cached';
import del from 'del';
import gulp from 'gulp';
import jest from 'gulp-jest';
import eslint from 'gulp-eslint';
import nodemon from 'gulp-nodemon';
import plumber from 'gulp-plumber';
import util from 'gulp-util';
import pkg from './package.json';
const paths = {
scripts: 'src/**/*.js',
tests: 'tests'
};
const config = {
db: new Config(pkg.name)
};
const jestDefaults = {
automock: false,
collectCoverage: false,
testEnvironment: 'node',
testRegex: '\\.test\\.js$'
};
gulp.task('reset', function(done) {
config.db.clear();
process.stdout.write(`\n> Settings deleted from ${config.db.path}\n\n`);
done();
});
gulp.task('lint', function() {
return gulp.src(paths.scripts)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('lint:informal', function() {
return gulp.src(paths.scripts)
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('lint:watch', gulp.series('lint:informal', function(done) {
gulp.watch(paths.scripts, gulp.series('lint:informal'));
done();
}));
gulp.task('test', function() {
const jestConfig = Object.assign({}, jestDefaults, { collectCoverage: false });
return gulp.src(paths.tests)
.pipe(jest({ config: jestConfig }));
});
gulp.task('test:coverage', function() {
const jestConfig = Object.assign({}, jestDefaults, { collectCoverage: true });
return gulp.src(paths.tests)
.pipe(jest({ config: jestConfig }));
});
gulp.task('test:informal', function(done) {
const jestConfig = Object.assign({}, jestDefaults);
return gulp.src(paths.tests)
.pipe(plumber(function (error) {
util.log(`Error: ${error.message}`);
done();
}))
.pipe(jest({ config: jestConfig }));
});
gulp.task('test:watch', gulp.series('test:informal', function(done) {
gulp.watch([paths.scripts, paths.tests], gulp.series('test:informal'));
done();
}));
gulp.task('build:clean', function(cb) {
del([
'lib/*',
], cb);
});
gulp.task('build:compile', function() {
return gulp.src(paths.scripts)
.pipe(cache('babel'))
.pipe(babel())
.pipe(gulp.dest('.'));
});
gulp.task('build:compile:informal', function() {
return gulp.src(paths.scripts)
.pipe(cache('babel'))
.pipe(plumber())
.pipe(babel())
.pipe(gulp.dest('.'));
});
gulp.task('build', gulp.series(
'lint', 'test:coverage', 'build:clean', 'build:compile'
));
gulp.task('build:informal', gulp.series(
'lint:informal', 'test:informal', 'build:clean', 'build:compile:informal'
));
gulp.task('build:refresh', gulp.series(
'lint', 'test', 'build:compile'
));
gulp.task('build:refresh:informal', gulp.series(
'lint:informal', 'test:informal', 'build:compile'
));
gulp.task('build:watch', gulp.series('build:informal', function(done) {
gulp.watch([paths.scripts, paths.tests], gulp.series('build:refresh:informal'));
done();
}));
gulp.task('develop:load', gulp.series(
'lint', 'test', 'build:clean', 'build:compile'
));
gulp.task('develop:reload', gulp.series(
'lint', 'test', 'build:compile'
));
gulp.task('develop', gulp.series('develop:load', function(done) {
nodemon({
script: 'bin/wowser-pipeline',
watch: ['src'],
tasks: ['develop:reload'],
delay: '250'
});
done();
}));
gulp.task('default', gulp.series('build'));