forked from unitycontainer/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (40 loc) · 1.02 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
var fs = require('fs');
var gulp = require('gulp');
var exec = require('gulp-exec');
var browserSync = require('browser-sync');
const config = 'docfx.json';
const server = browserSync.create();
function watched(){
var content = fs.readFileSync(config);
var json = JSON.parse(content);
return json.build.content.reduce(function(flat, section) {
return flat.concat(section.files);
}, []);
};
function reload(done){
server.reload();
done();
}
function serve(done){
server.init({
server: {
baseDir: './unitycontainer.github.io'
}
})
}
function build(){
var reportOptions = {
err: true,
stderr: true,
stdout: true
};
return gulp.src(config)
.pipe(exec('docfx <%= file.name %>'))
.pipe(exec.reporter(reportOptions));
}
const paths = watched();
const watch = () => gulp.watch(paths, gulp.series(build, reload));
exports.default = gulp.parallel(watch, serve);
exports.serve = serve;
exports.build = build;
exports.develop = exports.default;