mirror of
https://github.com/morluto/rea.git
synced 2026-10-29 19:05:45 +00:00
Centralize canonical system/user and deterministic renamed-bundle path facts. Reuse the installer destination and honor the same local candidates in doctor and runtime; scan renamed bundles only after canonical candidates fail. Preserve explicit path spelling and exclusive selection. Homebrew command probing remains doctor-only with explicit runtime configuration guidance. Validation: owner, config, setup and doctor tests cover canonical priority and renamed paths; public CLI verifies explicit path preservation without launching Hopper. No real Hopper analysis claimed. Fixes #3054 Related: #3085 Co-authored-by: Vinícius DS Andrade <95101505+viniciusdsandrade@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
import { mkdtemp, mkdir, rm } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
macHopperCanonicalLauncherCandidates,
|
|
macHopperLauncherCandidates,
|
|
macHopperRenamedLauncherCandidates,
|
|
} from "./MacHopperPaths.js";
|
|
|
|
describe("macOS Hopper launcher paths", () => {
|
|
const home = "/fixture/home";
|
|
|
|
it("keeps canonical system and user candidates ahead of renamed bundles", () => {
|
|
expect(macHopperCanonicalLauncherCandidates(home)).toEqual([
|
|
"/Applications/Hopper Disassembler.app/Contents/MacOS/hopper",
|
|
"/fixture/home/Applications/Hopper Disassembler.app/Contents/MacOS/hopper",
|
|
]);
|
|
expect(
|
|
macHopperRenamedLauncherCandidates(
|
|
home,
|
|
new Map([
|
|
[
|
|
"/Applications",
|
|
["Hopper z.app", "Hopper a.app", "Hopper Disassembler.app"],
|
|
],
|
|
["/fixture/home/Applications", ["Hopper User.app"]],
|
|
]),
|
|
),
|
|
).toEqual([
|
|
"/Applications/Hopper a.app/Contents/MacOS/hopper",
|
|
"/Applications/Hopper z.app/Contents/MacOS/hopper",
|
|
"/fixture/home/Applications/Hopper User.app/Contents/MacOS/hopper",
|
|
]);
|
|
});
|
|
|
|
it("always includes the installer's canonical user destination", () => {
|
|
expect(macHopperLauncherCandidates(home)).toContain(
|
|
"/fixture/home/Applications/Hopper Disassembler.app/Contents/MacOS/hopper",
|
|
);
|
|
});
|
|
|
|
it("finds renamed user bundles through the runtime filesystem scan", async () => {
|
|
const temporary = await mkdtemp(join(tmpdir(), "rea-hopper-paths-"));
|
|
const appDirectory = join(temporary, "Applications", "Hopper Preview.app");
|
|
try {
|
|
await mkdir(appDirectory, { recursive: true });
|
|
expect([...macHopperLauncherCandidates(temporary)]).toContain(
|
|
join(appDirectory, "Contents/MacOS/hopper"),
|
|
);
|
|
} finally {
|
|
await rm(temporary, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|