« get me outta code hell

write: live-dev-server: --serve-sfx - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-12-06 12:36:58 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-06 12:36:58 -0400
commitcdb0f981de1684d56dd268fe7dc663fa2ed979e1 (patch)
treec0167fe2376efa6de947e754757d690677e4a581 /src
parentd48874a4be60d7455dd6321742102c9cfb77a9f1 (diff)
write: live-dev-server: --serve-sfx
Diffstat (limited to 'src')
-rw-r--r--src/write/build-modes/live-dev-server.js11
1 files changed, 11 insertions, 0 deletions
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) {