mirror of
https://github.com/baairon/torlink.git
synced 2026-07-08 18:28:22 +02:00
fix: resolve clipboard write on exit for wrapped nix binaries (#57)
This commit is contained in:
@@ -20,7 +20,7 @@ describe("writeClipboard", () => {
|
||||
proc.kill = vi.fn();
|
||||
proc.stdin = {
|
||||
end: vi.fn(() => {
|
||||
queueMicrotask(() => proc.emit("close", cmd === "wl-copy" ? 0 : 1));
|
||||
queueMicrotask(() => proc.emit("exit", cmd === "wl-copy" ? 0 : 1));
|
||||
}),
|
||||
};
|
||||
return proc;
|
||||
|
||||
@@ -47,7 +47,9 @@ function write(cmd: string, args: string[], text: string): Promise<boolean> {
|
||||
}, 4000);
|
||||
timer.unref?.();
|
||||
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);
|
||||
} catch {
|
||||
resolve(false);
|
||||
|
||||
Reference in New Issue
Block a user