Skip to content

Commit 27b36f5

Browse files
Merge pull request #111 from alanconway/master
Revert gulpfile.js to work with gulp 3.9.1, update README-DEV to use …
2 parents 5563857 + 895a49e commit 27b36f5

2 files changed

Lines changed: 30 additions & 23 deletions

File tree

README-DEV.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ You can preview changes as you make them as follows:
77
1. Install the `antora` website generator and `gulp` build system
88
+
99
....
10-
npm install -g @antora/cli @antora/site-generator-default gulp gulp-connect gulp-open yaml-js
10+
npm install -g @antora/cli @antora/site-generator-default gulp@^3.9.1 gulp-connect yaml-js
1111
....
1212
1313
2. Create a `dev-site.yml` file (the `site.yml` file is for the public website)

gulpfile.js

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ const connect = require("gulp-connect");
44
const fs = require("fs");
55
const generator = require("@antora/site-generator-default");
66
const gulp = require("gulp");
7-
const open = require("gulp-open");
87
const yaml = require("yaml-js");
98

109
let filename = "dev-site.yml";
1110
let args = ["--playbook", filename];
1211

13-
function build(cb) {
12+
gulp.task("build", function(cb) {
1413
/**
1514
* Use the '@antora/site-generator-default' node module to build.
1615
* It's analogous to `$ antora --playbook local-antora-playbook.yml`.
@@ -20,36 +19,44 @@ function build(cb) {
2019
* a separate process for each run. So if a build error occurs with the `gulp`
2120
* command it can be useful to check if it also happens with the CLI command.
2221
*/
23-
generator(args, process.env).catch(err => { console.log(err); })
24-
connect.reload()
25-
cb();
26-
}
22+
generator(args, process.env)
23+
.then(() => {
24+
cb();
25+
})
26+
.catch(err => {
27+
console.log(err);
28+
cb();
29+
});
30+
});
2731

28-
function watch() {
32+
gulp.task("preview", ["build"], function() {
33+
/**
34+
* Remove the line gulp.src('README.adoc')
35+
* This is placeholder code to follow the gulp-connect
36+
* example. Could not make it work any other way.
37+
*/
38+
gulp.src("README.adoc").pipe(connect.reload());
39+
});
40+
41+
gulp.task("watch", function() {
2942
let json_content = fs.readFileSync(`${__dirname}/${filename}`, "UTF-8");
3043
let yaml_content = yaml.load(json_content);
31-
let sources = yaml_content.content.sources.map(source => [
32-
`${source.url}/**/*.yml`,
33-
`${source.url}/**/*.adoc`,
44+
let dirs = yaml_content.content.sources.map(source => [
45+
`${source.url}/**/**.yml`,
46+
`${source.url}/**/**.adoc`,
3447
`${source.url}/**/**.hbs`
3548
]);
36-
sources.push(["dev-site.yml"]);
37-
sources = [].concat.apply([], sources) // Flatten the array
38-
gulp.watch(sources, build)
39-
}
49+
dirs.push(["dev-site.yml"]);
50+
gulp.watch(dirs, ["preview"]);
51+
});
4052

41-
function serve() {
53+
gulp.task("connect", function() {
4254
connect.server({
4355
port: 5353,
4456
name: "Dev Server",
4557
livereload: true,
4658
root: "gh-pages"
4759
});
48-
}
49-
50-
function browse() {
51-
gulp.src("gh-pages/index.html").pipe(open({uri: 'http://localhost:5353'}))
52-
}
60+
});
5361

54-
exports.build = build;
55-
exports.default = gulp.parallel(serve, watch, browse)
62+
gulp.task("default", ["connect", "watch", "build"]);

0 commit comments

Comments
 (0)