UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

16 lines (15 loc) • 814 B
import path from "node:path"; //#region node-runtime-env.mjs /** Keep lifecycle children on the explicitly selected runtime without changing npm config. */ function withNodeRuntimePath(env, nodePath, platform = process.platform) { const paths = platform === "win32" ? path.win32 : path.posix; const keys = Object.keys(env).sort().filter((key) => platform === "win32" ? key.toUpperCase() === "PATH" : key === "PATH"); const key = keys[0] ?? "PATH"; const directory = paths.dirname(nodePath); const entries = (env[key] ? env[key].split(paths.delimiter) : []).filter((entry) => entry !== directory); const result = { ...env }; for (const pathKey of keys.length ? keys : [key]) result[pathKey] = [directory, ...entries].join(paths.delimiter); return result; } //#endregion export { withNodeRuntimePath as t };