fix(daemon): guard preferred node selection

This commit is contained in:
Sebastian
2026-02-17 10:01:37 -05:00
parent 3f66280c3c
commit 11fcbadec8
3 changed files with 34 additions and 1 deletions

View File

@@ -70,6 +70,31 @@ describe("resolvePreferredNodePath", () => {
expect(execFile).toHaveBeenCalledTimes(2);
});
it("ignores execPath when it is not node", async () => {
fsMocks.access.mockImplementation(async (target: string) => {
if (target === darwinNode) {
return;
}
throw new Error("missing");
});
const execFile = vi.fn().mockResolvedValue({ stdout: "22.12.0\n", stderr: "" });
const result = await resolvePreferredNodePath({
env: {},
runtime: "node",
platform: "darwin",
execFile,
execPath: "/Users/test/.bun/bin/bun",
});
expect(result).toBe(darwinNode);
expect(execFile).toHaveBeenCalledTimes(1);
expect(execFile).toHaveBeenCalledWith(darwinNode, ["-p", "process.versions.node"], {
encoding: "utf8",
});
});
it("uses system node when it meets the minimum version", async () => {
fsMocks.access.mockImplementation(async (target: string) => {
if (target === darwinNode) {