Skip to content

Node.js based forum software built for the modern web

refactor: send single message

Barış Soner Uşaklıdc37789b5dd4
diff --git a/Gruntfile.js b/Gruntfile.js
index 53a4b7e06f..60d8f8b23e 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -173,9 +173,10 @@ module.exports = function (grunt) {
winston.error(err.stack);
}
if (worker) {
- worker.send({ compiling: compiling });
- // Send livereload event via Socket.IO for instant browser refresh
- worker.send({ livereload: true });
+ worker.send({
+ compiling: compiling,
+ livereload: true, // Send livereload event via Socket.IO for instant browser refresh
+ });
}
});
});
diff --git a/src/start.js b/src/start.js
index a15aa44c6a..c4dd925aad 100644
--- a/src/start.js
+++ b/src/start.js
@@ -107,20 +107,24 @@ function addProcessHandlers() {
shutdown(1);
});
process.on('message', (msg) => {
- if (msg && Array.isArray(msg.compiling)) {
- if (msg.compiling.includes('tpl')) {
- const benchpressjs = require('benchpressjs');
- benchpressjs.flush();
- } else if (msg.compiling.includes('lang')) {
- const translator = require('./translator');
- translator.flush();
+ if (msg) {
+ if (Array.isArray(msg.compiling)) {
+ if (msg.compiling.includes('tpl')) {
+ const benchpressjs = require('benchpressjs');
+ benchpressjs.flush();
+ } else if (msg.compiling.includes('lang')) {
+ const translator = require('./translator');
+ translator.flush();
+ }
}
- } else if (msg && msg.livereload) {
- // Send livereload event to all connected clients via Socket.IO
- const websockets = require('./socket.io');
- if (websockets.server) {
- websockets.server.emit('event:livereload');
- winston.info('[livereload] Sent reload event to all clients');
+
+ if (msg.livereload) {
+ // Send livereload event to all connected clients via Socket.IO
+ const websockets = require('./socket.io');
+ if (websockets.server) {
+ websockets.server.emit('event:livereload');
+ winston.info('[livereload] Sent reload event to all clients');
+ }
}
}
});