Files
rea/src/application/homebrew.ts
T
morluto 4dec415fc8 Remove dead exports found by knip
- Un-export HOMEBREW_COMMANDS, systemSetupHost, ToolKind, BinaryArchitecture,
  HopperDiagnostic -- only consumed within their own files
- Remove unused HopperUnavailableError class (never instantiated)
- Reformat knip.json entry/project arrays to multi-line
2026-07-12 10:20:45 +08:00

22 lines
685 B
TypeScript

/** Standard executable names and locations used to discover Homebrew. */
const HOMEBREW_COMMANDS = [
"brew",
"/opt/homebrew/bin/brew",
"/usr/local/bin/brew",
] as const;
/**
* Return the first defined result from standard Homebrew executables.
* A probe returning `undefined` means that location was unavailable or failed;
* other falsy values are successful results and stop discovery.
*/
export const probeHomebrew = async <T>(
probe: (command: string) => Promise<T | undefined>,
): Promise<T | undefined> => {
for (const command of HOMEBREW_COMMANDS) {
const result = await probe(command);
if (result !== undefined) return result;
}
return undefined;
};