« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/upd8.js30
-rw-r--r--src/write/build-modes/live-dev-server.js13
-rw-r--r--src/write/build-modes/static-build.js11
3 files changed, 22 insertions, 32 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 9e4ef4fb..609a758d 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -2382,29 +2382,37 @@ async function main() {
   logInfo`Passing control over to build mode: ${selectedBuildModeFlag}`;
   console.log('');
 
+  const universalUtilities = {
+    getSizeOfAdditionalFile,
+    getSizeOfImagePath,
+
+    defaultLanguage: finalDefaultLanguage,
+    developersComment,
+    languages,
+    missingImagePaths,
+    thumbsCache,
+    urlSpec,
+    urls,
+    wikiData,
+  };
+
   try {
     buildModeResult = await selectedBuildMode.go({
       cliOptions,
+      queueSize,
+
+      universalUtilities,
+      ...universalUtilities,
+
       dataPath,
       mediaPath,
       mediaCachePath,
       wikiCachePath,
-      queueSize,
       srcRootPath: __dirname,
 
-      defaultLanguage: finalDefaultLanguage,
-      languages,
-      missingImagePaths,
-      thumbsCache,
-      urls,
-      urlSpec,
       webRoutes: preparedWebRoutes,
-      wikiData,
 
       closeLanguageWatchers,
-      developersComment,
-      getSizeOfAdditionalFile,
-      getSizeOfImagePath,
       niceShowAggregate,
     });
   } catch (error) {
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index c855533b..c0b8c800 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -167,6 +167,8 @@ export async function go({
   contentDependenciesWatcher.on('error', () => {});
   await new Promise(resolve => contentDependenciesWatcher.once('ready', resolve));
 
+  const commonUtilities = {...universalUtilities};
+
   let targetSpecPairs = getPageSpecsWithTargets({wikiData});
   const pages = progressCallAll(`Computing page data & paths for ${targetSpecPairs.length} targets.`,
     targetSpecPairs.flatMap(({
@@ -332,17 +334,6 @@ export async function go({
 
     // Other routes determined by page and URL specs
 
-    const commonUtilities = {
-      defaultLanguage,
-      getSizeOfAdditionalFile,
-      getSizeOfImagePath,
-      languages,
-      missingImagePaths,
-      thumbsCache,
-      urls,
-      wikiData,
-    };
-
     const startTiming = () => {
       if (!showTimings) {
         return () => '';
diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js
index d743a64b..3f829ada 100644
--- a/src/write/build-modes/static-build.js
+++ b/src/write/build-modes/static-build.js
@@ -288,16 +288,7 @@ export async function go({
     showAggregate: niceShowAggregate,
   });
 
-  const commonUtilities = {
-    defaultLanguage,
-    getSizeOfAdditionalFile,
-    getSizeOfImagePath,
-    languages,
-    missingImagePaths,
-    thumbsCache,
-    urls,
-    wikiData,
-  };
+  const commonUtilities = {...universalUtilities};
 
   const perLanguageFn = async (language, i, entries) => {
     const baseDirectory =