« get me outta code hell

write: live-dev-server: add --skip-serving option for perf testing - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write/build-modes
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-05 16:25:40 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-05 16:25:40 -0400
commitff9ebc7232645971783c444d9a58953ebfd2da37 (patch)
tree2e8f8060a4e8919d914c739e7c3e5a044666cfa4 /src/write/build-modes
parent778ad4cafbc45a7de5e6251f317c62d115380c0b (diff)
write: live-dev-server: add --skip-serving option for perf testing
Diffstat (limited to 'src/write/build-modes')
-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;
 }