-
Notifications
You must be signed in to change notification settings - Fork 27
/
gulpfile.js
50 lines (40 loc) · 1.4 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
'use strict';
const gulp = require('gulp');
const pluginerror = require('plugin-error');
const browsersync = require('browser-sync').create();
const del = require('del');
const spawn = require('child_process').spawn;
function shell(plugin, command, args) {
return (done) =>
spawn(command, args, {stdio: 'inherit'})
.on('error', (err) => {
done(new pluginerror(plugin, err))
})
.on('exit', (code) => {
if (code == 0) {
// Process completed successfully
done()
} else {
done(new pluginerror(plugin, `Process failed with exit code ${code}`));
}
})
}
function webserver(done) {
browsersync.init({
watch: true,
server: "./build/dev/html/"
}, function () { this.server.on('close', done) })
};
function watch() {
gulp.watch('./docs/source/**', gulp.series('sphinx:dev'));
};
gulp.task('clean', () => del(['build']));
gulp.task('sphinx', shell(
'sphinx', 'sphinx-build', ['-W', '-d', 'build/doctrees', 'docs/source', 'build/html']
));
gulp.task('sphinx:dev', shell(
'sphinx', 'sphinx-build', ['docs/source', 'build/dev/html']
));
gulp.task('build', gulp.series('clean', 'sphinx'));
gulp.task('build:dev', gulp.series('clean', 'sphinx:dev'));
gulp.task('default', gulp.series('build:dev', gulp.parallel(webserver, watch)));