mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:51:24 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -5,7 +5,7 @@ import { isTruthyEnvValue } from "./env.js";
|
||||
|
||||
import { resolveBrewPathDirs } from "./brew.js";
|
||||
|
||||
type EnsureMoltbotPathOpts = {
|
||||
type EnsureOpenClawPathOpts = {
|
||||
execPath?: string;
|
||||
cwd?: string;
|
||||
homeDir?: string;
|
||||
@@ -48,7 +48,7 @@ function mergePath(params: { existing: string; prepend: string[] }): string {
|
||||
return merged.join(path.delimiter);
|
||||
}
|
||||
|
||||
function candidateBinDirs(opts: EnsureMoltbotPathOpts): string[] {
|
||||
function candidateBinDirs(opts: EnsureOpenClawPathOpts): string[] {
|
||||
const execPath = opts.execPath ?? process.execPath;
|
||||
const cwd = opts.cwd ?? process.cwd();
|
||||
const homeDir = opts.homeDir ?? os.homedir();
|
||||
@@ -56,19 +56,19 @@ function candidateBinDirs(opts: EnsureMoltbotPathOpts): string[] {
|
||||
|
||||
const candidates: string[] = [];
|
||||
|
||||
// Bundled macOS app: `moltbot` lives next to the executable (process.execPath).
|
||||
// Bundled macOS app: `openclaw` lives next to the executable (process.execPath).
|
||||
try {
|
||||
const execDir = path.dirname(execPath);
|
||||
const siblingMoltbot = path.join(execDir, "moltbot");
|
||||
if (isExecutable(siblingMoltbot)) candidates.push(execDir);
|
||||
const siblingCli = path.join(execDir, "openclaw");
|
||||
if (isExecutable(siblingCli)) candidates.push(execDir);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
// Project-local installs (best effort): if a `node_modules/.bin/moltbot` exists near cwd,
|
||||
// Project-local installs (best effort): if a `node_modules/.bin/openclaw` exists near cwd,
|
||||
// include it. This helps when running under launchd or other minimal PATH environments.
|
||||
const localBinDir = path.join(cwd, "node_modules", ".bin");
|
||||
if (isExecutable(path.join(localBinDir, "moltbot"))) candidates.push(localBinDir);
|
||||
if (isExecutable(path.join(localBinDir, "openclaw"))) candidates.push(localBinDir);
|
||||
|
||||
const miseDataDir = process.env.MISE_DATA_DIR ?? path.join(homeDir, ".local", "share", "mise");
|
||||
const miseShims = path.join(miseDataDir, "shims");
|
||||
@@ -91,12 +91,14 @@ function candidateBinDirs(opts: EnsureMoltbotPathOpts): string[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* Best-effort PATH bootstrap so skills that require the `moltbot` CLI can run
|
||||
* Best-effort PATH bootstrap so skills that require the `openclaw` CLI can run
|
||||
* under launchd/minimal environments (and inside the macOS app bundle).
|
||||
*/
|
||||
export function ensureMoltbotCliOnPath(opts: EnsureMoltbotPathOpts = {}) {
|
||||
if (isTruthyEnvValue(process.env.CLAWDBOT_PATH_BOOTSTRAPPED)) return;
|
||||
process.env.CLAWDBOT_PATH_BOOTSTRAPPED = "1";
|
||||
export function ensureOpenClawCliOnPath(opts: EnsureOpenClawPathOpts = {}) {
|
||||
if (isTruthyEnvValue(process.env.OPENCLAW_PATH_BOOTSTRAPPED)) {
|
||||
return;
|
||||
}
|
||||
process.env.OPENCLAW_PATH_BOOTSTRAPPED = "1";
|
||||
|
||||
const existing = opts.pathEnv ?? process.env.PATH ?? "";
|
||||
const prepend = candidateBinDirs(opts);
|
||||
|
||||
Reference in New Issue
Block a user