mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:48:26 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -9,6 +9,9 @@ export type CommandRunner = (
|
||||
options: { timeoutMs: number; cwd?: string; env?: NodeJS.ProcessEnv },
|
||||
) => Promise<{ stdout: string; stderr: string; code: number | null }>;
|
||||
|
||||
const PRIMARY_PACKAGE_NAME = "openclaw";
|
||||
const ALL_PACKAGE_NAMES = [PRIMARY_PACKAGE_NAME] as const;
|
||||
|
||||
async function pathExists(targetPath: string): Promise<boolean> {
|
||||
try {
|
||||
await fs.access(targetPath);
|
||||
@@ -51,7 +54,7 @@ export async function resolveGlobalPackageRoot(
|
||||
): Promise<string | null> {
|
||||
const root = await resolveGlobalRoot(manager, runCommand, timeoutMs);
|
||||
if (!root) return null;
|
||||
return path.join(root, "moltbot");
|
||||
return path.join(root, PRIMARY_PACKAGE_NAME);
|
||||
}
|
||||
|
||||
export async function detectGlobalInstallManagerForRoot(
|
||||
@@ -75,14 +78,18 @@ export async function detectGlobalInstallManagerForRoot(
|
||||
const globalRoot = res.stdout.trim();
|
||||
if (!globalRoot) continue;
|
||||
const globalReal = await tryRealpath(globalRoot);
|
||||
const expected = path.join(globalReal, "moltbot");
|
||||
if (path.resolve(expected) === path.resolve(pkgReal)) return manager;
|
||||
for (const name of ALL_PACKAGE_NAMES) {
|
||||
const expected = path.join(globalReal, name);
|
||||
if (path.resolve(expected) === path.resolve(pkgReal)) return manager;
|
||||
}
|
||||
}
|
||||
|
||||
const bunGlobalRoot = resolveBunGlobalRoot();
|
||||
const bunGlobalReal = await tryRealpath(bunGlobalRoot);
|
||||
const bunExpected = path.join(bunGlobalReal, "moltbot");
|
||||
if (path.resolve(bunExpected) === path.resolve(pkgReal)) return "bun";
|
||||
for (const name of ALL_PACKAGE_NAMES) {
|
||||
const bunExpected = path.join(bunGlobalReal, name);
|
||||
if (path.resolve(bunExpected) === path.resolve(pkgReal)) return "bun";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -94,11 +101,15 @@ export async function detectGlobalInstallManagerByPresence(
|
||||
for (const manager of ["npm", "pnpm"] as const) {
|
||||
const root = await resolveGlobalRoot(manager, runCommand, timeoutMs);
|
||||
if (!root) continue;
|
||||
if (await pathExists(path.join(root, "moltbot"))) return manager;
|
||||
for (const name of ALL_PACKAGE_NAMES) {
|
||||
if (await pathExists(path.join(root, name))) return manager;
|
||||
}
|
||||
}
|
||||
|
||||
const bunRoot = resolveBunGlobalRoot();
|
||||
if (await pathExists(path.join(bunRoot, "moltbot"))) return "bun";
|
||||
for (const name of ALL_PACKAGE_NAMES) {
|
||||
if (await pathExists(path.join(bunRoot, name))) return "bun";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user