« get me outta code hell

upd8: add verifyImagePaths to stepStatusSummary - 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>2023-10-30 16:57:52 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-30 16:57:52 -0300
commit47db4cec1b6203a4c14f6d01f396c2418787146a (patch)
treec3be09082b9cb8c6f6fa7d0eb3262e9c73c57b2d
parentef6cdf04af3d73d5d42f9665511082a146091109 (diff)
upd8: add verifyImagePaths to stepStatusSummary
-rwxr-xr-xsrc/upd8.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 5515f5d7..c7fe0ca5 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -150,6 +150,9 @@ async function main() {
     initializeDefaultLanguage:
       {...defaultStepStatus, name: `initialize default language`},
 
+    verifyImagePaths:
+      {...defaultStepStatus, name: `verify missing/misplaced image paths`},
+
     preloadFileSizes:
       {...defaultStepStatus, name: `preload file sizes`},
 
@@ -970,9 +973,30 @@ async function main() {
 
   const urls = generateURLs(urlSpec);
 
-  const {missing: missingImagePaths} =
+  stepStatusSummary.verifyImagePaths.status = STATUS_STARTED_NOT_DONE;
+
+  const {missing: missingImagePaths, misplaced: misplacedImagePaths} =
     await verifyImagePaths(mediaPath, {urls, wikiData});
 
+  if (empty(missingImagePaths) && empty(misplacedImagePaths)) {
+    stepStatusSummary.verifyImagePaths.status = STATUS_DONE_CLEAN;
+  } else if (empty(missingImagePaths)) {
+    Object.assign(stepStatusSummary.verifyImagePaths, {
+      status: STATUS_HAS_WARNINGS,
+      annotation: `misplaced images detected`,
+    });
+  } else if (empty(misplacedImagePaths)) {
+    Object.assign(stepStatusSummary.verifyImagePaths, {
+      status: STATUS_HAS_WARNINGS,
+      annotation: `missing images detected`,
+    });
+  } else {
+    Object.assign(stepStatusSummary.verifyImagePaths, {
+      status :STATUS_HAS_WARNINGS,
+      annotation: `missing and misplaced images detected`,
+    });
+  }
+
   const fileSizePreloader = new FileSizePreloader();
 
   // File sizes of additional files need to be precalculated before we can