diff options
Diffstat (limited to 'src/write')
-rw-r--r-- | src/write/bind-utilities.js | 29 | ||||
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 17 |
2 files changed, 13 insertions, 33 deletions
diff --git a/src/write/bind-utilities.js b/src/write/bind-utilities.js index d6053353..2ddc2b38 100644 --- a/src/write/bind-utilities.js +++ b/src/write/bind-utilities.js @@ -4,13 +4,6 @@ import chroma from 'chroma-js'; -import { - replacerSpec, - transformInline, - // transformLyrics, - // transformMultiline, -} from '../util/transform-content.js'; - import * as html from '../util/html.js'; import {bindOpts} from '../util/sugar.js'; @@ -57,28 +50,6 @@ export function bindUtilities({ bound.find = bindFind(wikiData, {mode: 'warn'}); - bound.transformInline = bindOpts(transformInline, { - find: bound.find, - link: bound.link, - replacerSpec, - language, - to, - wikiData, - }); - - /* - bound.transformMultiline = bindOpts(transformMultiline, { - img: bound.img, - to, - transformInline: bound.transformInline, - }); - - bound.transformLyrics = bindOpts(transformLyrics, { - transformInline: bound.transformInline, - transformMultiline: bound.transformMultiline, - }); - */ - /* bound.generateNavigationLinks = bindOpts(generateNavigationLinks, { link: bound.link, diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index d7c33d87..78c3928f 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -56,6 +56,11 @@ export function getCLIOptions() { return true; }, }, + + 'quiet-responses': { + help: `Disables outputting [200] and [404] responses in the server log`, + type: 'flag', + }, }; } @@ -86,6 +91,7 @@ export async function go({ const host = cliOptions['host'] ?? defaultHost; const port = parseInt(cliOptions['port'] ?? defaultPort); + const quietResponses = cliOptions['quiet-responses'] ?? false; const contentDependenciesWatcher = await watchContentDependencies(); const {contentDependencies: allContentDependencies} = contentDependenciesWatcher; @@ -167,7 +173,7 @@ export async function go({ }); response.writeHead(200, contentTypeJSON); response.end(json); - console.log(`${requestHead} [200] /data.json`); + if (!quietResponses) console.log(`${requestHead} [200] /data.json`); } catch (error) { response.writeHead(500, contentTypeJSON); response.end({error: `Internal error serializing wiki JSON`}); @@ -263,7 +269,7 @@ export async function go({ await pipeline( createReadStream(filePath), response); - console.log(`${requestHead} [200] ${pathname}`); + if (!quietResponses) console.log(`${requestHead} [200] ${pathname}`); } catch (error) { response.writeHead(500, contentTypePlain); response.end(`Failed during file-to-response pipeline`); @@ -281,7 +287,7 @@ export async function go({ if (!Object.hasOwn(urlToPageMap, pathnameKey)) { response.writeHead(404, contentTypePlain); response.end(`No page found for: ${pathnameKey}\n`); - console.log(`${requestHead} [404] ${pathname}`); + if (!quietResponses) console.log(`${requestHead} [404] ${pathname}`); return; } @@ -462,7 +468,7 @@ export async function go({ const pageHTML = topLevelResult.toString(); - console.log(`${requestHead} [200] ${pathname}`); + if (!quietResponses) console.log(`${requestHead} [200] ${pathname}`); response.writeHead(200, contentTypeHTML); response.end(pageHTML); } catch (error) { @@ -492,6 +498,9 @@ export async function go({ server.on('listening', () => { logInfo`${'All done!'} Listening at: ${address}`; logInfo`Press ^C here (control+C) to stop the server and exit.`; + if (quietResponses) { + logInfo`Suppressing [200] and [404] response logging.`; + } }); server.listen(port, host); |