Files
openclaw/packages/normalization-core/src/stable-node-path.ts
loong 7bdd1f646b fix(memory-host-sdk): resolve stable execPath for worker fork to survive Homebrew Node upgrades (#99318)
* fix(memory): survive Homebrew Node upgrades

Co-authored-by: 袁龙辉0668001277 <yuan.longhui@xydigit.com>

* test(whatsapp): isolate last-route coverage

* fix(deepinfra): preserve offline model compatibility

* test(memory): isolate migration cleanup lifecycle

* test: stabilize aggregate extension gates

* ci: retrigger pull request workflow

* test: preserve inherited Node options

* test(cli): tolerate cold hosted startup

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-29 06:49:02 -04:00

26 lines
960 B
TypeScript

import path from "node:path";
import { expectDefined } from "./expect.js";
/**
* Returns stable Homebrew paths for a versioned Cellar Node executable.
* Availability remains caller-owned so packages can reuse the path contract
* without importing another package's filesystem/runtime layer.
*/
export function stableHomebrewNodePathCandidates(nodePath: string): string[] {
const cellarMatch = nodePath.match(
/^(.+?)[\\/]Cellar[\\/]([^\\/]+)[\\/][^\\/]+[\\/]bin[\\/]node$/,
);
if (!cellarMatch) {
return [];
}
const prefix = expectDefined(cellarMatch[1], "cellar match capture group 1");
const formula = expectDefined(cellarMatch[2], "cellar match capture group 2");
const pathModule = nodePath.includes("\\") ? path.win32 : path.posix;
const candidates = [pathModule.join(prefix, "opt", formula, "bin", "node")];
if (formula === "node") {
candidates.push(pathModule.join(prefix, "bin", "node"));
}
return candidates;
}