Add NodeCG preflight step and sanity script

This commit is contained in:
Pandipipas
2026-03-03 00:07:12 +01:00
parent 02b8fe71ac
commit 9481052749
5 changed files with 37 additions and 1 deletions
+7 -1
View File
@@ -30,6 +30,7 @@ type NodecgProcessManagerDeps = {
};
export type NodecgProcessManager = {
runPreflightChecks: () => Promise<void>;
startNodecgProcess: () => Promise<ChildProcess>;
waitForNodecgReady: (startTime: number) => Promise<void>;
stopNodecgProcessGracefully: () => Promise<void>;
@@ -51,7 +52,7 @@ export function createNodecgProcessManager({
let lastExit: { code: number | null; signal: NodeJS.Signals | null } | null = null;
let lastStderrLine: string | null = null;
const startNodecgProcess = async (): Promise<ChildProcess> => {
const runPreflightChecks = async (): Promise<void> => {
validateNodecgInstall(
nodecgRootPath,
resolvedDeps.platform,
@@ -66,6 +67,10 @@ export function createNodecgProcessManager({
`Port ${appConfig.nodecgPort} is already in use. Stop the process using it or set NODECG_PORT before starting.`,
);
}
};
const startNodecgProcess = async (): Promise<ChildProcess> => {
await runPreflightChecks();
const command = resolvedDeps.platform === "win32" ? "npx.cmd" : "npx";
const child = resolvedDeps.spawnProcess(command, ["nodecg", "start"], {
@@ -186,6 +191,7 @@ export function createNodecgProcessManager({
};
return {
runPreflightChecks,
startNodecgProcess,
waitForNodecgReady,
stopNodecgProcessGracefully,