forked from SpongePowered/SpongeDocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
51 lines (42 loc) · 1.37 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
const
gulp = require('gulp'),
gutil = require('gulp-util'),
del = require('del'),
spawn = require('child_process').spawn,
webserver = require('gulp-webserver');
gulp.task('clean', () => del(['build']));
function shell(plugin, command, args) {
return (done) =>
spawn(command, args, {stdio: 'inherit'})
.on('error', (err) => {
done(new gutil.PluginError(plugin, err))
})
.on('exit', (code) => {
if (code == 0) {
// Process completed successfully
done()
} else {
done(new gutil.PluginError(plugin, `Process failed with exit code ${code}`));
}
})
}
gulp.task('sphinx', shell(
'sphinx', 'sphinx-build', ['-W', '-d', 'build/doctrees', 'source', 'build/html']
));
gulp.task('sphinx:dev', shell(
'sphinx', 'sphinx-build', ['source', 'build/dev/html']
));
gulp.task('build', ['clean', 'sphinx']);
// TODO: Don't stop watching if Sphinx or Sass throws an error
gulp.task('watch', ['clean', 'sphinx:dev'], () =>
gulp.watch('./source/**', ['sphinx:dev'])
);
gulp.task('webserver', ['watch'], () =>
gulp.src('build/dev/html')
.pipe(webserver({
livereload: true,
enable: true,
open: true
}))
);
gulp.task('default', ['webserver']);