« get me outta code hell

quick-reload HSMusic-dedicated data tests - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-12-06 17:02:50 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-12-06 17:02:50 -0400
commit0fc9972296f19c5da546861b9f3bb6d08c007d20 (patch)
tree808ca28e45896fa4b06f355f7b5ef11fdbffdb17 /src
parent04acee7dfdaf81f8c548cd8ed1031cd01b1396b4 (diff)
quick-reload HSMusic-dedicated data tests
Diffstat (limited to 'src')
-rwxr-xr-xsrc/upd8.js30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 217c985d..70297c6c 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -60,6 +60,7 @@ import find, {bindFind} from './util/find.js';
 import * as html from './util/html.js';
 import {getColors} from './util/colors.js';
 import {findFiles} from './util/io.js';
+import {isMain} from './util/node-utils.js';
 
 import CacheableObject from './data/things/cacheable-object.js';
 
@@ -1599,7 +1600,8 @@ function generateRedirectPage(title, target, {language}) {
   ]);
 }
 
-async function processLanguageFile(file) {
+// TODO: define somewhere besides upd8.js obviously
+export async function processLanguageFile(file) {
   const contents = await readFile(file, 'utf-8');
   const json = JSON.parse(contents);
 
@@ -2608,15 +2610,17 @@ async function main() {
   logInfo`Written!`;
 }
 
-main()
-  .catch((error) => {
-    if (error instanceof AggregateError) {
-      showAggregate(error);
-    } else {
-      console.error(error);
-    }
-  })
-  .then(() => {
-    decorateTime.displayTime();
-    CacheableObject.showInvalidAccesses();
-  });
+if (isMain(import.meta.url)) {
+  main()
+    .catch((error) => {
+      if (error instanceof AggregateError) {
+        showAggregate(error);
+      } else {
+        console.error(error);
+      }
+    })
+    .then(() => {
+      decorateTime.displayTime();
+      CacheableObject.showInvalidAccesses();
+    });
+}