« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write/build-modes
diff options
context:
space:
mode:
Diffstat (limited to 'src/write/build-modes')
-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) {