« 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.js44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/upd8.js b/src/upd8.js
index c18a0c54..a5fb8ced 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -423,6 +423,37 @@ async function main() {
     ...buildOptions,
   });
 
+  // Most of the time we'll need a build mode specified to do anything useful,
+  // but a few options make it OK to go ahead without (i.e, ones which never
+  // advance to the build). Note that we can only identify this after loading
+  // all options.
+
+  const buildlessOptions = [
+    'help',
+    'migrate-thumbs',
+    'no-build',
+    'thumbs-only',
+  ];
+
+  const buildModeRequired =
+    buildlessOptions.every(option => !cliOptions[option]);
+
+  // If we're going to require a build mode and none is specified,
+  // exit and show what to do.
+
+  if (buildModeRequired && !selectedBuildMode) {
+    showHelpForOptions({
+      heading: `Please specify a build mode:`,
+      options: buildModeFlagOptions,
+    });
+
+    console.log(
+      `(Use ${colors.bright('--help')} for general info and all options, or specify\n` +
+      ` a build mode alongside ${colors.bright('--help')} for that mode's options!`);
+
+    return false;
+  }
+
   if (cliOptions['help']) {
     console.log(
       colors.bright(`hsmusic (aka. Homestuck Music Wiki, HSMusic Wiki)\n`) +
@@ -484,19 +515,6 @@ async function main() {
     return true;
   }
 
-  // At this point we need to have a build mode to do anything useful, so exit
-  // and show what to do, if none was specified.
-  if (!selectedBuildMode) {
-    showHelpForOptions({
-      heading: `Please specify a build mode:`,
-      options: buildModeFlagOptions,
-    });
-    console.log(
-      `(Use ${colors.bright('--help')} for general info and all options, or specify\n` +
-      ` a build mode alongside ${colors.bright('--help')} for that mode's options!`);
-    return false;
-  }
-
   const dataPath = cliOptions['data-path'] || process.env.HSMUSIC_DATA;
   const mediaPath = cliOptions['media-path'] || process.env.HSMUSIC_MEDIA;
   const wikiCachePath = cliOptions['cache-path'] || process.env.HSMUSIC_CACHE;