-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathgulpfile.js
More file actions
64 lines (51 loc) · 1.66 KB
/
gulpfile.js
File metadata and controls
64 lines (51 loc) · 1.66 KB
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
'use strict';
import gulp from 'gulp';
import pluginerror from 'plugin-error';
import browsersync from 'browser-sync';
import {deleteAsync} from 'del';
import { spawn } from 'child_process';
const docsDir = "docs";
const ignoredPaths = [
"config/documentation/objects",
"config/documentation/configs",
"install/versions.rst",
"install/versions/platforms",
];
function shell(plugin, command, args) {
return (done) => {
const child = spawn(command, args, { stdio: 'inherit' });
child.on('error', (err) => {
done(new pluginerror(plugin, err));
});
child.on('exit', (code) => {
if (code === 0) {
// Process completed successfully
done();
} else {
done(new pluginerror(plugin, `Process failed with exit code ${code}`));
}
});
};
}
function webserver(done) {
const server = browsersync.create();
server.init({
watch: true,
server: "./build/dev/html/"
}, function () {
this.server.on('close', done);
});
}
function watch() {
gulp.watch([`./${docsDir}/**`, ...ignoredPaths.map(dir => `!./${docsDir}/${dir}`)], gulp.series('sphinx:dev'));
}
gulp.task('clean', () => deleteAsync(['build']));
gulp.task('sphinx', shell(
'sphinx', 'sphinx-build', ['-W', '-d', 'build/doctrees', docsDir, 'build/html']
));
gulp.task('sphinx:dev', shell(
'sphinx', 'sphinx-build', [docsDir, '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)));