« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/upd8.js82
-rw-r--r--src/write/build-modes/live-dev-server.js4
-rw-r--r--src/write/build-modes/static-build.js4
3 files changed, 62 insertions, 28 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 6105565c..19a12de4 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -285,6 +285,11 @@ async function main() {
       type: 'flag',
     },
 
+    'skip-media-validation': {
+      help: `Skips checking and reporting missing and misplaced media files, which isn't necessary if you aren't adding or removing data or updating directories`,
+      type: 'flag',
+    },
+
     // Just working on data entries and not interested in actually
     // generating site HTML yet? This flag will cut execution off right
     // 8efore any site 8uilding actually happens.
@@ -641,6 +646,18 @@ async function main() {
       },
     });
 
+    fallbackStep('verifyImagePaths', {
+      default: 'perform',
+      buildConfig: 'skipMediaValidation',
+      cli: {
+        flag: 'skip-media-validation',
+        negate: true,
+        warning:
+          `Skipping media validation. If any media files are missing or misplaced,\n` +
+          `those errors will be silently passed along to the build.`,
+      },
+    });
+
     fallbackStep('watchLanguageFiles', {
       default: 'perform',
       buildConfig: 'languageReloading',
@@ -1555,37 +1572,46 @@ async function main() {
 
   const urls = generateURLs(urlSpec);
 
-  Object.assign(stepStatusSummary.verifyImagePaths, {
-    status: STATUS_STARTED_NOT_DONE,
-    timeStart: Date.now(),
-  });
-
-  const {missing: missingImagePaths, misplaced: misplacedImagePaths} =
-    await verifyImagePaths(mediaPath, {urls, wikiData});
+  let missingImagePaths;
 
-  if (empty(missingImagePaths) && empty(misplacedImagePaths)) {
-    Object.assign(stepStatusSummary.verifyImagePaths, {
-      status: STATUS_DONE_CLEAN,
-      timeEnd: Date.now(),
-    });
-  } else if (empty(missingImagePaths)) {
-    Object.assign(stepStatusSummary.verifyImagePaths, {
-      status: STATUS_HAS_WARNINGS,
-      annotation: `misplaced images detected`,
-      timeEnd: Date.now(),
-    });
-  } else if (empty(misplacedImagePaths)) {
+  if (stepStatusSummary.verifyImagePaths.status === STATUS_NOT_APPLICABLE) {
+    missingImagePaths = [];
+  } else if (stepStatusSummary.verifyImagePaths.status === STATUS_NOT_STARTED) {
     Object.assign(stepStatusSummary.verifyImagePaths, {
-      status: STATUS_HAS_WARNINGS,
-      annotation: `missing images detected`,
-      timeEnd: Date.now(),
-    });
-  } else {
-    Object.assign(stepStatusSummary.verifyImagePaths, {
-      status: STATUS_HAS_WARNINGS,
-      annotation: `missing and misplaced images detected`,
-      timeEnd: Date.now(),
+      status: STATUS_STARTED_NOT_DONE,
+      timeStart: Date.now(),
     });
+
+    const results =
+      await verifyImagePaths(mediaPath, {urls, wikiData});
+
+    missingImagePaths = results.missing;
+    const misplacedImagePaths = results.misplaced;
+
+    if (empty(missingImagePaths) && empty(misplacedImagePaths)) {
+      Object.assign(stepStatusSummary.verifyImagePaths, {
+        status: STATUS_DONE_CLEAN,
+        timeEnd: Date.now(),
+      });
+    } else if (empty(missingImagePaths)) {
+      Object.assign(stepStatusSummary.verifyImagePaths, {
+        status: STATUS_HAS_WARNINGS,
+        annotation: `misplaced images detected`,
+        timeEnd: Date.now(),
+      });
+    } else if (empty(misplacedImagePaths)) {
+      Object.assign(stepStatusSummary.verifyImagePaths, {
+        status: STATUS_HAS_WARNINGS,
+        annotation: `missing images detected`,
+        timeEnd: Date.now(),
+      });
+    } else {
+      Object.assign(stepStatusSummary.verifyImagePaths, {
+        status: STATUS_HAS_WARNINGS,
+        annotation: `missing and misplaced images detected`,
+        timeEnd: Date.now(),
+      });
+    }
   }
 
   Object.assign(stepStatusSummary.preloadFileSizes, {
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index ecd1d954..0d16911a 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -30,6 +30,10 @@ export const config = {
     default: true,
   },
 
+  mediaValidation: {
+    default: true,
+  },
+
   thumbs: {
     default: true,
   },
diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js
index bed24332..65fea6f1 100644
--- a/src/write/build-modes/static-build.js
+++ b/src/write/build-modes/static-build.js
@@ -42,6 +42,10 @@ export const config = {
     applicable: false,
   },
 
+  mediaValidation: {
+    default: true,
+  },
+
   thumbs: {
     default: true,
   },