From ff9ebc7232645971783c444d9a58953ebfd2da37 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 5 Nov 2023 16:25:40 -0400 Subject: write: live-dev-server: add --skip-serving option for perf testing --- src/write/build-modes/live-dev-server.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/write') 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; } -- cgit 1.3.0-6-gf8a5