UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

29 lines (28 loc) • 1.18 kB
import { c as resolveUserPath } from "./home-dir-EKmgmdPG.mjs"; import "./utils-C8YECn2Q.mjs"; import { i as resolveEnvironmentValue } from "./process-env-DVJdcOcM.mjs"; import { a as resolveExecutableFromPathEnv, n as isExecutableFile } from "./executable-path-D8oWZRS5.mjs"; import { t as isSafeExecutableValue } from "./exec-safety-DkenKsFz.mjs"; import path from "node:path"; //#region src/infra/detect-binary.ts /** Return true when a safe executable name/path can be found on this host. */ async function detectBinary(e) { if (!isSafeExecutableValue(e)) return false; const t = e.startsWith("~") ? resolveUserPath(e) : e; if (path.isAbsolute(t) || t.startsWith(".") || t.includes("/") || t.includes("\\")) return isExecutableFile(t); try { const t = process.cwd(); const n = resolveEnvironmentValue(process.env, "PATH") ?? ""; const r = process.platform === "win32" ? `${t};${n}` : n; const i = process.platform === "win32" ? path.extname(e) : ""; const a = i ? { PATHEXT: i } : process.env; return Boolean(resolveExecutableFromPathEnv(e, r, a, { cwd: t, useCache: false })); } catch { return false; } } //#endregion export { detectBinary as t };