mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
chore: clean NodeCG install validation checks
This commit is contained in:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user