mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:38:27 +00:00
fix: add fallback for Control UI asset resolution in global installs
This commit is contained in:
@@ -54,10 +54,35 @@ export async function resolveControlUiDistIndexPath(
|
||||
}
|
||||
|
||||
const packageRoot = await resolveOpenClawPackageRoot({ argv1: normalized });
|
||||
if (!packageRoot) {
|
||||
return null;
|
||||
if (packageRoot) {
|
||||
return path.join(packageRoot, "dist", "control-ui", "index.html");
|
||||
}
|
||||
return path.join(packageRoot, "dist", "control-ui", "index.html");
|
||||
|
||||
// Fallback: traverse up and find package.json with name "openclaw" + dist/control-ui/index.html
|
||||
// This handles global installs where path-based resolution might fail.
|
||||
let dir = path.dirname(normalized);
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const pkgJsonPath = path.join(dir, "package.json");
|
||||
const indexPath = path.join(dir, "dist", "control-ui", "index.html");
|
||||
if (fs.existsSync(pkgJsonPath) && fs.existsSync(indexPath)) {
|
||||
try {
|
||||
const raw = fs.readFileSync(pkgJsonPath, "utf-8");
|
||||
const parsed = JSON.parse(raw) as { name?: unknown };
|
||||
if (parsed.name === "openclaw") {
|
||||
return indexPath;
|
||||
}
|
||||
} catch {
|
||||
// Invalid package.json, continue searching
|
||||
}
|
||||
}
|
||||
const parent = path.dirname(dir);
|
||||
if (parent === dir) {
|
||||
break;
|
||||
}
|
||||
dir = parent;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export type ControlUiRootResolveOptions = {
|
||||
|
||||
Reference in New Issue
Block a user