fix: resolve clipboard write on exit for wrapped nix binaries (#57)

This commit is contained in:
Abu Hossain Foysal
2026-07-06 23:33:31 -04:00
committed by GitHub
parent c63187ecc1
commit 26a4f0f910
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ describe("writeClipboard", () => {
proc.kill = vi.fn(); proc.kill = vi.fn();
proc.stdin = { proc.stdin = {
end: vi.fn(() => { end: vi.fn(() => {
queueMicrotask(() => proc.emit("close", cmd === "wl-copy" ? 0 : 1)); queueMicrotask(() => proc.emit("exit", cmd === "wl-copy" ? 0 : 1));
}), }),
}; };
return proc; return proc;
+3 -1
View File
@@ -47,7 +47,9 @@ function write(cmd: string, args: string[], text: string): Promise<boolean> {
}, 4000); }, 4000);
timer.unref?.(); timer.unref?.();
proc.on("error", () => done(false)); proc.on("error", () => done(false));
proc.on("close", (code) => done(code === 0)); const onFinish = (code: number | null = 0): void => done(code === 0);
proc.on("exit", onFinish);
proc.on("close", onFinish);
proc.stdin?.end(text); proc.stdin?.end(text);
} catch { } catch {
resolve(false); resolve(false);