Spaces:
Runtime error
Runtime error
File size: 917 Bytes
cd8bd0a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import { execSync } from "node:child_process";
export function copyToClipboard(text) {
try {
const execOpts = { input: text, stdio: ["pipe", "ignore", "ignore"], timeout: 2000 };
if (process.platform === "darwin") {
execSync("pbcopy", execOpts);
} else if (process.platform === "win32") {
execSync("clip", execOpts);
} else {
try {
execSync("xclip -selection clipboard", execOpts);
} catch {
try {
execSync("xsel --clipboard --input", execOpts);
} catch {
execSync("wl-copy", execOpts);
}
}
}
return true;
} catch {
return false;
}
}
export function isClipboardSupported() {
if (process.platform === "darwin" || process.platform === "win32") return true;
try {
execSync("which xclip || which xsel || which wl-copy", { stdio: "ignore" });
return true;
} catch {
return false;
}
}
|