fix: livereload not working on second try (#1103)

* Fix livereload on second try

* fix lint

* Rename to LIVERELOAD_PORT
This commit is contained in:
Andrew Low 2018-11-11 06:36:11 -08:00 committed by Endilie Yacop Sucipto
parent 7aba299a3b
commit 49af2075b5

View file

@ -9,10 +9,9 @@ const gaze = require('gaze');
const tinylr = require('tiny-lr');
const readMetadata = require('./readMetadata.js');
let reloadScriptUrl;
function start(port) {
process.env.NODE_ENV = 'development';
process.env.LIVERELOAD_PORT = port;
const server = tinylr();
server.listen(port, () => {
console.log('LiveReload server started on port %d', port);
@ -26,11 +25,12 @@ function start(port) {
});
},
);
reloadScriptUrl = `http://localhost:${port}/livereload.js`;
}
const getReloadScriptUrl = () => reloadScriptUrl;
const getReloadScriptUrl = () => {
const port = process.env.LIVERELOAD_PORT;
return `http://localhost:${port}/livereload.js`;
};
module.exports = {
start,