chore: clean NodeCG install validation checks

This commit is contained in:
Pandipipas
2026-03-02 23:57:40 +01:00
parent eae612cb38
commit 73cdde3f5c
2 changed files with 9 additions and 16 deletions
+7 -16
View File
@@ -52,12 +52,7 @@ export function createNodecgProcessManager({
let lastStderrLine: string | null = null;
const startNodecgProcess = async (): Promise<ChildProcess> => {
validateNodecgInstall(
nodecgRootPath,
appConfig.bundleName,
resolvedDeps.pathExists,
resolvedDeps.hasReadWriteAccess,
);
validateNodecgInstall(nodecgRootPath, resolvedDeps.platform, resolvedDeps.pathExists, resolvedDeps.hasReadWriteAccess);
const portAsNumber = Number.parseInt(appConfig.nodecgPort, 10);
const isPortAvailable = await resolvedDeps.probePortAvailable(portAsNumber);
@@ -211,17 +206,13 @@ function resolveDeps(deps?: Partial<NodecgProcessManagerDeps>): NodecgProcessMan
function validateNodecgInstall(
nodecgRootPath: string,
bundleName: string,
platform: NodeJS.Platform,
pathExists: (candidatePath: string) => boolean,
hasReadWriteAccessToPath: (candidatePath: string) => boolean,
): void {
const packageJsonPath = path.join(nodecgRootPath, "package.json");
const nodecgCliPath = path.join(
nodecgRootPath,
"node_modules",
".bin",
process.platform === "win32" ? "nodecg.cmd" : "nodecg",
);
const nodecgDependencyPath = path.join(nodecgRootPath, "node_modules", "nodecg", "package.json");
const nodecgCliPath = path.join(nodecgRootPath, "node_modules", ".bin", platform === "win32" ? "nodecg.cmd" : "nodecg");
const bundleAssetDirs = ["dashboard", "graphics", "extension", "extensions"].map((dir) =>
path.join(nodecgRootPath, dir),
);
@@ -238,11 +229,11 @@ function validateNodecgInstall(
throw new Error(`${packageJsonPath} was not found. Expected a NodeCG bundle app at lib/scoreko-dev.`);
}
if (!pathExists(nodecgCliPath)) {
if (!pathExists(nodecgDependencyPath) || !pathExists(nodecgCliPath)) {
throw new Error(
[
"NodeCG dependency is missing in lib/scoreko-dev.",
`Not found: ${nodecgCliPath}`,
`Not found: ${nodecgDependencyPath} and/or ${nodecgCliPath}`,
"Solution: enter lib/scoreko-dev and install dependencies:",
" npm install",
].join("\n"),
@@ -252,7 +243,7 @@ function validateNodecgInstall(
if (!bundleAssetDirs.some((candidatePath) => pathExists(candidatePath))) {
throw new Error(
[
`Bundle '${bundleName}' appears incomplete.`,
"scoreko-dev bundle appears incomplete.",
`Expected one of: ${bundleAssetDirs.join(", ")}`,
"Ensure extensions/dashboard/graphics assets exist inside lib/scoreko-dev.",
].join("\n"),