From cdb0f981de1684d56dd268fe7dc663fa2ed979e1 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 6 Dec 2023 12:36:58 -0400 Subject: write: live-dev-server: --serve-sfx --- src/write/build-modes/live-dev-server.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/write/build-modes') diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index 8828a5bd..b0272809 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -1,3 +1,4 @@ +import {spawn} from 'node:child_process'; import * as http from 'node:http'; import {readFile, stat} from 'node:fs/promises'; import * as path from 'node:path'; @@ -45,6 +46,11 @@ export function getCLIOptions() { type: 'flag', }, + 'serve-sfx': { + help: `Plays the specified sound file once the HTTP server is ready (this requires mpv)`, + type: 'value', + }, + 'skip-serving': { help: `Causes the build to exit when it would start serving over HTTP instead\n\nMainly useful for testing performance`, type: 'flag', @@ -84,6 +90,7 @@ export async function go({ const port = parseInt(cliOptions['port'] ?? defaultPort); const loudResponses = cliOptions['loud-responses'] ?? false; const skipServing = cliOptions['skip-serving'] ?? false; + const serveSFX = cliOptions['serve-sfx'] ?? null; const contentDependenciesWatcher = await watchContentDependencies(); const {contentDependencies} = contentDependenciesWatcher; @@ -401,6 +408,10 @@ export async function go({ logInfo`Suppressing [200] and [404] response logging.` logInfo`(Pass --loud-responses to show these.)`; } + + if (serveSFX) { + spawn('mpv', [serveSFX, '--volume=75']); + } }); if (skipServing) { -- cgit 1.3.0-6-gf8a5