fix(cli): harden service lifecycle edge cases

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-07-22 19:38:47 +00:00
1 parent c18d1d378f
commit ed4eaf6f46
8 files changed
+72 -22

No files matched your search

+13 -1
View File
@@ -79,8 +79,20 @@ describe("managed install commands", () => {
const userData = path.join(process.env.PAPERCLIP_HOME!, "instances", "default", "keep.txt");
fs.mkdirSync(path.dirname(userData), { recursive: true });
fs.writeFileSync(userData, "keep");
await uninstallCommand();
const uninstallService = vi.fn(async () => {
expect(fs.existsSync(paths.shimPath)).toBe(true);
});
await uninstallCommand({
detectServiceManager: vi.fn(async () => ({
supported: true as const,
manager: {
status: vi.fn(async () => ({ installed: true, active: true })),
uninstall: uninstallService,
} as never,
})),
});
expect(uninstallService).toHaveBeenCalledOnce();
expect(fs.existsSync(paths.cliRoot)).toBe(false);
expect(fs.existsSync(paths.shimPath)).toBe(false);
expect(fs.readFileSync(userData, "utf8")).toBe("keep");