« get me outta code hell

infra: log as content functions errors fixed, even before ready - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-01 13:48:29 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-01 20:06:24 -0400
commit1fdbc0d9fde7205a04ee98f064bdc8f12867b788 (patch)
tree1432b4203a7006d70f354cd131a464724ae1b31b
parent2ab124884fa3d0f9c74dd52e3e823d08b4b01a6d (diff)
infra: log as content functions errors fixed, even before ready
-rw-r--r--src/content/dependencies/index.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/content/dependencies/index.js b/src/content/dependencies/index.js
index 95247e9c..28755f7b 100644
--- a/src/content/dependencies/index.js
+++ b/src/content/dependencies/index.js
@@ -35,6 +35,7 @@ export function watchContentDependencies({
   const contentDependencies = {};
 
   let emittedReady = false;
+  let emittedErrorForFunctions = new Set();
   let closed = false;
 
   let _close = () => {};
@@ -201,7 +202,8 @@ export function watchContentDependencies({
         break main;
       }
 
-      if (logging && emittedReady) {
+      const emittedError = emittedErrorForFunctions.has(functionName);
+      if (logging && (emittedReady || emittedError)) {
         const timestamp = new Date().toLocaleString('en-US', {timeStyle: 'medium'});
         console.log(colors.green(`[${timestamp}] Updated ${functionName}`));
       }
@@ -221,6 +223,7 @@ export function watchContentDependencies({
     }
 
     events.emit('error', functionName, error);
+    emittedErrorForFunctions.add(functionName);
 
     if (logging) {
       if (contentDependencies[functionName]) {