mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 14:51:24 +00:00
refactor: dedupe core config and runtime helpers
This commit is contained in:
@@ -47,6 +47,17 @@ function addCommonUserBinDirs(dirs: string[], home: string): void {
|
||||
dirs.push(`${home}/.bun/bin`);
|
||||
}
|
||||
|
||||
function addCommonEnvConfiguredBinDirs(
|
||||
dirs: string[],
|
||||
env: Record<string, string | undefined> | undefined,
|
||||
): void {
|
||||
addNonEmptyDir(dirs, env?.PNPM_HOME);
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.NPM_CONFIG_PREFIX, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.BUN_INSTALL, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.VOLTA_HOME, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.ASDF_DATA_DIR, "shims"));
|
||||
}
|
||||
|
||||
function resolveSystemPathDirs(platform: NodeJS.Platform): string[] {
|
||||
if (platform === "darwin") {
|
||||
return ["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin"];
|
||||
@@ -78,11 +89,7 @@ export function resolveDarwinUserBinDirs(
|
||||
// Env-configured bin roots (override defaults when present).
|
||||
// Note: FNM_DIR on macOS defaults to ~/Library/Application Support/fnm
|
||||
// Note: PNPM_HOME on macOS defaults to ~/Library/pnpm
|
||||
addNonEmptyDir(dirs, env?.PNPM_HOME);
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.NPM_CONFIG_PREFIX, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.BUN_INSTALL, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.VOLTA_HOME, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.ASDF_DATA_DIR, "shims"));
|
||||
addCommonEnvConfiguredBinDirs(dirs, env);
|
||||
// nvm: no stable default path, relies on env or user's shell config
|
||||
// User must set NVM_DIR and source nvm.sh for it to work
|
||||
addNonEmptyDir(dirs, env?.NVM_DIR);
|
||||
@@ -120,11 +127,7 @@ export function resolveLinuxUserBinDirs(
|
||||
const dirs: string[] = [];
|
||||
|
||||
// Env-configured bin roots (override defaults when present).
|
||||
addNonEmptyDir(dirs, env?.PNPM_HOME);
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.NPM_CONFIG_PREFIX, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.BUN_INSTALL, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.VOLTA_HOME, "bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.ASDF_DATA_DIR, "shims"));
|
||||
addCommonEnvConfiguredBinDirs(dirs, env);
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.NVM_DIR, "current/bin"));
|
||||
addNonEmptyDir(dirs, appendSubdir(env?.FNM_DIR, "current/bin"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user