Add browser reload on file change/rebuild

Add browser reload on file change/rebuild
This commit is contained in:
StevenJNPearce 2018-09-16 02:26:37 +02:00 committed by Pascal Precht
parent f378ea55da
commit 5917e0cb5a
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 67 additions and 13 deletions

View File

@ -5,6 +5,7 @@ const expressWebSocket = require('express-ws');
const express = require('express'); const express = require('express');
const fs = require('../../core/fs'); const fs = require('../../core/fs');
require('http-shutdown').extend(); require('http-shutdown').extend();
const webSocket = require('ws');
class Server { class Server {
constructor(options) { constructor(options) {
@ -36,6 +37,15 @@ class Server {
this.app.use(main); this.app.use(main);
this.app.use('/coverage', coverage); this.app.use('/coverage', coverage);
this.app.use(coverageStyle); this.app.use(coverageStyle);
//this.wss = new webSocket.Server({server: this.server});
//this.events.on('outputDone', () => {
// this.wss.clients.forEach((ws) => {
// if (ws.readyState === webSocket.OPEN) {
// ws.send('outputDone');
// }
// });
//});
this.app.ws('/', (_ws, _req) => {}); this.app.ws('/', (_ws, _req) => {});
const wss = expressWs.getWss('/'); const wss = expressWs.getWss('/');

70
npm-shrinkwrap.json generated
View File

@ -3975,11 +3975,13 @@
}, },
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true "bundled": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -3992,15 +3994,18 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -4103,7 +4108,8 @@
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true "bundled": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -4113,6 +4119,7 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -4125,17 +4132,20 @@
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true "bundled": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -4152,6 +4162,7 @@
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -4224,7 +4235,8 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -4234,6 +4246,7 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -4339,6 +4352,7 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -8754,7 +8768,7 @@
"serve-static": { "serve-static": {
"version": "1.13.2", "version": "1.13.2",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz",
"integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", "integrity": "sha1-CV6Ecv1bRiN9tQzkhqQ/S4bGzsE=",
"requires": { "requires": {
"encodeurl": "~1.0.2", "encodeurl": "~1.0.2",
"escape-html": "~1.0.3", "escape-html": "~1.0.3",
@ -9721,6 +9735,18 @@
"servify": "^0.1.12", "servify": "^0.1.12",
"ws": "^3.0.0", "ws": "^3.0.0",
"xhr-request-promise": "^0.1.2" "xhr-request-promise": "^0.1.2"
},
"dependencies": {
"ws": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz",
"integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==",
"requires": {
"async-limiter": "~1.0.0",
"safe-buffer": "~5.1.0",
"ultron": "~1.1.0"
}
}
} }
} }
} }
@ -10871,6 +10897,18 @@
"servify": "^0.1.12", "servify": "^0.1.12",
"ws": "^3.0.0", "ws": "^3.0.0",
"xhr-request-promise": "^0.1.2" "xhr-request-promise": "^0.1.2"
},
"dependencies": {
"ws": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz",
"integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==",
"requires": {
"async-limiter": "~1.0.0",
"safe-buffer": "~5.1.0",
"ultron": "~1.1.0"
}
}
} }
}, },
"underscore": { "underscore": {
@ -11069,13 +11107,19 @@
} }
}, },
"ws": { "ws": {
"version": "3.3.3", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-3.0.0.tgz",
"integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", "integrity": "sha1-mN2wAFbIOQy3Ued4h4hJf5kQO2w=",
"requires": { "requires": {
"async-limiter": "~1.0.0", "safe-buffer": "~5.0.1",
"safe-buffer": "~5.1.0",
"ultron": "~1.1.0" "ultron": "~1.1.0"
},
"dependencies": {
"safe-buffer": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz",
"integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c="
}
} }
}, },
"xhr": { "xhr": {