Improve Hopper session reliability

This commit is contained in:
morluto
2026-07-12 06:53:31 +08:00
parent ee6d539a40
commit d9c9025ffb
11 changed files with 124 additions and 80 deletions
+5 -7
View File
@@ -15,6 +15,7 @@ import { z } from "zod";
import { PRODUCT_IDENTITY } from "../identity.js";
import { runDoctor, systemDoctorHost } from "./Doctor.js";
import { probeHomebrew } from "./homebrew.js";
const execFileAsync = promisify(execFile);
@@ -271,13 +272,10 @@ const commandSucceeds = async (
}
};
const brewSucceeds = async (args: readonly string[]): Promise<boolean> => {
for (const command of [
"brew",
"/opt/homebrew/bin/brew",
"/usr/local/bin/brew",
])
if (await commandSucceeds(command, args)) return true;
return false;
const result = await probeHomebrew(async (command) =>
(await commandSucceeds(command, args)) ? true : undefined,
);
return result === true;
};
const major = (version: string): number =>
Number.parseInt(version.split(".")[0] ?? "0", 10);