« 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:
-rw-r--r--src/write/build-modes/live-dev-server.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index 47d59f95..ab6ceecb 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -44,6 +44,11 @@ export function getCLIOptions() {
       help: `Enables outputting [200] and [404] responses in the server log, which are suppressed by default`,
       type: 'flag',
     },
+
+    'skip-serving': {
+      help: `Causes the build to exit when it would start serving over HTTP instead\n\nMainly useful for testing performance`,
+      type: 'flag',
+    },
   };
 }
 
@@ -78,6 +83,7 @@ export async function go({
   const host = cliOptions['host'] ?? defaultHost;
   const port = parseInt(cliOptions['port'] ?? defaultPort);
   const loudResponses = cliOptions['loud-responses'] ?? false;
+  const skipServing = cliOptions['skip-serving'] ?? false;
 
   const contentDependenciesWatcher = await watchContentDependencies();
   const {contentDependencies} = contentDependenciesWatcher;
@@ -396,10 +402,14 @@ export async function go({
     }
   });
 
-  server.listen(port, host);
+  if (skipServing) {
+    logInfo`Ready to serve! But --skip-serving was passed, so all done.`;
+  } else {
+    server.listen(port, host);
 
-  // Just keep going... forever!!!
-  await new Promise(() => {});
+    // Just keep going... forever!!!
+    await new Promise(() => {});
+  }
 
   return true;
 }