-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
66 lines (56 loc) · 2.18 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
'use strict';
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')();
const del = require('del');
const exec = require('child_process').exec;
const babelConfig = {
presets: [
// {'retainLines': true} // broken in babel 7 with decorators
],
'plugins': [['@babel/plugin-proposal-decorators', { 'legacy': true }]]
};
gulp.task('lint', gulp.series(function lint () {
return gulp.src(['./lib/**/*.js', './test/**/*.js', 'gulpfile.js'])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
}));
gulp.task('docs', gulp.series(function docs (done) {
exec(`node ./node_modules/documentation/bin/documentation.js build lib/ravel.js -f html -o docs-dist -c documentation.yml --theme ./documentation_theme`, (err, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
if (err) { done(err); } else {
gulp.src(['docs-dist/index.html'])
// fake decorator support
.pipe(plugins.replace(/<span class="hljs-comment">\/\/\s+&#64;(.*?)<\/span>/g, (match, group1) => {
return `@${group1.replace(/'(.+?)'/g, '<span class="hljs-string">\'$1\'</span>')}`;
}))
.pipe(gulp.dest('docs-dist/'))
.on('end', done);
}
});
}));
gulp.task('clean', gulp.series(function clean () {
return del([
'coverage', 'docs-dist', 'test-dist'
]);
}));
// TODO broken babel reference
gulp.task('dist', gulp.series('clean', function dist () {
return gulp.src('lib/**/*.js')
.pipe(plugins.babel(babelConfig))
.pipe(gulp.dest('dist'));
}));
gulp.task('watch', gulp.series(gulp.parallel('lint', 'docs'), function watch () {
gulp.watch(['README.md', './lib/**/*.js', './docs/**/*.md', 'documentation.yml', './documentation_theme/**'], gulp.parallel('lint', 'docs'));
gulp.watch(['gulpfile.js', './test/**/*.js'], gulp.parallel('lint'));
}));
gulp.task('show-coverage', gulp.series(function showCoverage () {
return gulp.src('./coverage/lcov-report/index.html')
.pipe(plugins.open());
}));
gulp.task('show-docs', gulp.series('docs', function showDocs () {
return gulp.src('./docs-dist/index.html')
.pipe(plugins.open());
}));
gulp.task('default', gulp.series('watch'));