diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-11-09 14:42:24 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-11-09 14:42:24 -0400 |
commit | aa30c888ea2307931c555db474d709f520c551a8 (patch) | |
tree | b23042b5b575862d83f401b5fa21f8b45f7988ff /src/write | |
parent | e71230340181a3b7b38ff05ba23504b264f5b26c (diff) | |
parent | b62622d3cd8ffe1ed517ceb873d9352943c4a601 (diff) |
Merge branch 'preview' into listing-tweaks
Diffstat (limited to 'src/write')
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 21 | ||||
-rw-r--r-- | src/write/build-modes/static-build.js | 6 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index 1339c322..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', + }, }; } @@ -51,6 +56,7 @@ export async function go({ cliOptions, _dataPath, mediaPath, + mediaCachePath, defaultLanguage, languages, @@ -77,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; @@ -171,7 +178,7 @@ export async function go({ const { area: localFileArea, path: localFilePath - } = pathname.match(/^\/(?<area>static|util|media)\/(?<path>.*)/)?.groups ?? {}; + } = pathname.match(/^\/(?<area>static|util|media|thumb)\/(?<path>.*)/)?.groups ?? {}; if (localFileArea) { // Not security tested, man, this is a dev server!! @@ -182,6 +189,8 @@ export async function go({ localDirectory = path.join(srcRootPath, localFileArea); } else if (localFileArea === 'media') { localDirectory = mediaPath; + } else if (localFileArea === 'thumb') { + localDirectory = mediaCachePath; } let filePath; @@ -393,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; } diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index 09316999..b6dc9643 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -84,6 +84,7 @@ export async function go({ cliOptions, _dataPath, mediaPath, + mediaCachePath, queueSize, defaultLanguage, @@ -133,6 +134,7 @@ export async function go({ await writeSymlinks({ srcRootPath, mediaPath, + mediaCachePath, outputPath, urls, }); @@ -372,6 +374,8 @@ export async function go({ logWarn`available - albeit possibly outdated! Please scroll up and send`; logWarn`the HSMusic developers a copy of the errors:`; fileIssue({topMessage: null}); + + return false; } return true; @@ -414,6 +418,7 @@ async function writePage({ function writeSymlinks({ srcRootPath, mediaPath, + mediaCachePath, outputPath, urls, }) { @@ -421,6 +426,7 @@ function writeSymlinks({ link(path.join(srcRootPath, 'util'), 'shared.utilityRoot'), link(path.join(srcRootPath, 'static'), 'shared.staticRoot'), link(mediaPath, 'media.root'), + link(mediaCachePath, 'thumb.root'), ]); async function link(directory, urlKey) { |