MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / detectProvider

Function detectProvider

packages/cli/src/utils/clipboard.ts:17–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15}
16
17function detectProvider(): ClipboardProvider | undefined {
18 const os = platform();
19 if (os === "darwin") {
20 return { cmd: "pbcopy", args: [] };
21 }
22 if (os === "win32") {
23 return { cmd: "clip.exe", args: [] };
24 }
25 // Linux / BSD — pick the first tool that's on PATH.
26 // WSL exposes clip.exe too; prefer it so copies land in the Windows
27 // clipboard where the user actually sees them.
28 const candidates: ClipboardProvider[] = [
29 { cmd: "clip.exe", args: [] },
30 { cmd: "wl-copy", args: [] },
31 { cmd: "xclip", args: ["-selection", "clipboard"] },
32 { cmd: "xsel", args: ["--clipboard", "--input"] },
33 ];
34 const cmd = process.platform === "win32" ? "where" : "which";
35 for (const p of candidates) {
36 const result = spawnSync(cmd, [p.cmd], { stdio: "ignore" });
37 if (result.status === 0) return p;
38 }
39 return undefined;
40}
41
42let cachedProvider: ClipboardProvider | undefined | null = null;
43

Callers 1

copyToClipboardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected