forked from openactive/open-booking-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
68 lines (53 loc) · 1.59 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"use strict";
var gulp = require('gulp')
const fetchAndWrite = require("./node_modules/respec/tools/respecDocWriter.js").fetchAndWrite;
gulp.task('express', function() {
var express = require('express');
var app = express();
app.use(require('connect-livereload')({port: 35729}));
app.use(express.static(__dirname));
app.use(express.static(__dirname + "/respec")) ; //Respec dev mode
app.listen(4000, '0.0.0.0');
});
var tinylr;
gulp.task('livereload', function() {
tinylr = require('tiny-lr')();
tinylr.listen(35729);
});
function notifyLiveReload(event) {
var fileName = require('path').relative(__dirname, event.path);
console.log("Changed: " + fileName);
tinylr.changed({
body: {
files: [fileName]
}
});
}
function notifyEditorsDraft() {
console.log("Changed: Editor's Draft");
tinylr.changed({
body: {
files: ["EditorsDraft/edit.html"]
}
});
}
gulp.task('editorsdraft', function() {
var fs = require('fs'),
path = require('path');
var thisDir = path.dirname(fs.realpathSync(__filename));
const src = "http://localhost:4000/EditorsDraft/edit.html";
console.log(src);
const out = "./EditorsDraft/index.html";
const whenToHalt = {
haltOnError: false,
haltOnWarn: false,
};
const timeout = 10000;
return fetchAndWrite(src, out, whenToHalt, timeout).then(notifyEditorsDraft);
});
gulp.task('watch', function() {
gulp.watch('EditorsDraft/edit.html', ['editorsdraft']);
//gulp.watch('EditorsDraft/live.html', notifyLiveReload);
});
gulp.task('default', ['editorsdraft', 'express', 'livereload', 'watch'], function() {
});