juxscript 1.1.75 ā 1.1.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dom-structure-map.json +1 -1
- package/machinery/serve.js +4 -8
- package/package.json +1 -1
package/dom-structure-map.json
CHANGED
package/machinery/serve.js
CHANGED
|
@@ -208,6 +208,7 @@ app.get('*', (req, res) => {
|
|
|
208
208
|
const server = http.createServer(app);
|
|
209
209
|
let wss = null;
|
|
210
210
|
let watcher = null;
|
|
211
|
+
let publicWatcher = null; // ā
Declare at top level
|
|
211
212
|
|
|
212
213
|
if (HOT_RELOAD) {
|
|
213
214
|
wss = new WebSocketServer({ port: WS_PORT });
|
|
@@ -263,7 +264,7 @@ if (HOT_RELOAD) {
|
|
|
263
264
|
if (fs.existsSync(paths.public)) {
|
|
264
265
|
console.log(`š Watching public assets: ${paths.public}`);
|
|
265
266
|
|
|
266
|
-
|
|
267
|
+
publicWatcher = createWatcher(paths.public, {
|
|
267
268
|
onChange: async (changedFiles) => {
|
|
268
269
|
console.log('š¦ Public asset changed, copying...');
|
|
269
270
|
|
|
@@ -280,13 +281,6 @@ if (HOT_RELOAD) {
|
|
|
280
281
|
// Silent, already logged main watcher
|
|
281
282
|
}
|
|
282
283
|
});
|
|
283
|
-
|
|
284
|
-
// ā
Store reference for cleanup
|
|
285
|
-
const originalShutdown = shutdown;
|
|
286
|
-
shutdown = () => {
|
|
287
|
-
if (publicWatcher) publicWatcher.close();
|
|
288
|
-
originalShutdown();
|
|
289
|
-
};
|
|
290
284
|
}
|
|
291
285
|
}
|
|
292
286
|
|
|
@@ -300,9 +294,11 @@ server.listen(PORT, () => {
|
|
|
300
294
|
}
|
|
301
295
|
});
|
|
302
296
|
|
|
297
|
+
// ā
Define shutdown AFTER all variables are initialized
|
|
303
298
|
const shutdown = () => {
|
|
304
299
|
console.log('\nš Shutting down...');
|
|
305
300
|
if (watcher) watcher.close();
|
|
301
|
+
if (publicWatcher) publicWatcher.close(); // ā
Close public watcher
|
|
306
302
|
if (wss) {
|
|
307
303
|
wss.clients.forEach(client => client.terminate());
|
|
308
304
|
wss.close();
|