-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
windows.js
23 lines (18 loc) · 826 Bytes
/
windows.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import {execa, execaSync} from 'execa';
import {is64bitSync} from 'is64bit';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const binarySuffix = is64bitSync() ? 'x86_64' : 'i686';
// Binaries from: https://github.com/sindresorhus/win-clipboard
const windowBinaryPath = path.join(__dirname, `../fallbacks/windows/clipboard_${binarySuffix}.exe`);
const clipboard = {
copy: async options => execa(windowBinaryPath, ['--copy'], options),
async paste(options) {
const {stdout} = await execa(windowBinaryPath, ['--paste'], options);
return stdout;
},
copySync: options => execaSync(windowBinaryPath, ['--copy'], options),
pasteSync: options => execaSync(windowBinaryPath, ['--paste'], options).stdout,
};
export default clipboard;