aboutsummaryrefslogtreecommitdiff
path: root/node_modules/clipboardy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/clipboardy/lib')
-rw-r--r--node_modules/clipboardy/lib/linux.js48
-rw-r--r--node_modules/clipboardy/lib/macos.js11
-rw-r--r--node_modules/clipboardy/lib/termux.js29
-rw-r--r--node_modules/clipboardy/lib/windows.js16
4 files changed, 104 insertions, 0 deletions
diff --git a/node_modules/clipboardy/lib/linux.js b/node_modules/clipboardy/lib/linux.js
new file mode 100644
index 00000000..a93cbf60
--- /dev/null
+++ b/node_modules/clipboardy/lib/linux.js
@@ -0,0 +1,48 @@
+'use strict';
+const path = require('path');
+const execa = require('execa');
+
+const handler = err => {
+ if (err.code === 'ENOENT') {
+ throw new Error('Couldn\'t find the required `xsel` binary. On Debian/Ubuntu you can install it with: sudo apt install xsel');
+ }
+
+ throw err;
+};
+
+const xsel = path.join(__dirname, '../fallbacks/linux/xsel');
+
+module.exports = {
+ copy: opts => {
+ return execa(xsel, ['--clipboard', '--input'], opts)
+ .catch(() => execa('xsel', ['--clipboard', '--input'], opts))
+ .catch(handler);
+ },
+ paste: opts => {
+ return execa.stdout(xsel, ['--clipboard', '--output'], opts)
+ .catch(() => execa.stdout('xsel', ['--clipboard', '--output'], opts))
+ .catch(handler);
+ },
+ copySync: opts => {
+ try {
+ return execa.sync(xsel, ['--clipboard', '--input'], opts);
+ } catch (err) {
+ try {
+ return execa.sync('xsel', ['--clipboard', '--input'], opts);
+ } catch (err) {
+ handler(err);
+ }
+ }
+ },
+ pasteSync: opts => {
+ try {
+ return execa.sync(xsel, ['--clipboard', '--output'], opts);
+ } catch (err) {
+ try {
+ return execa.sync('xsel', ['--clipboard', '--output'], opts);
+ } catch (err) {
+ handler(err);
+ }
+ }
+ }
+};
diff --git a/node_modules/clipboardy/lib/macos.js b/node_modules/clipboardy/lib/macos.js
new file mode 100644
index 00000000..d25305b4
--- /dev/null
+++ b/node_modules/clipboardy/lib/macos.js
@@ -0,0 +1,11 @@
+'use strict';
+const execa = require('execa');
+
+const env = Object.assign({}, process.env, {LC_CTYPE: 'UTF-8'});
+
+module.exports = {
+ copy: opts => execa('pbcopy', Object.assign({}, opts, {env})),
+ paste: opts => execa.stdout('pbpaste', Object.assign({}, opts, {env})),
+ copySync: opts => execa.sync('pbcopy', Object.assign({}, opts, {env})),
+ pasteSync: opts => execa.sync('pbpaste', Object.assign({}, opts, {env}))
+};
diff --git a/node_modules/clipboardy/lib/termux.js b/node_modules/clipboardy/lib/termux.js
new file mode 100644
index 00000000..67050193
--- /dev/null
+++ b/node_modules/clipboardy/lib/termux.js
@@ -0,0 +1,29 @@
+'use strict';
+const execa = require('execa');
+
+const handler = err => {
+ if (err.code === 'ENOENT') {
+ throw new Error('Couldn\'t find the termux-api scripts. You can install them with: apt install termux-api');
+ }
+
+ throw err;
+};
+
+module.exports = {
+ copy: opts => execa('termux-clipboard-set', opts).catch(handler),
+ paste: opts => execa.stdout('termux-clipboard-get', opts).catch(handler),
+ copySync: opts => {
+ try {
+ return execa.sync('termux-clipboard-set', opts);
+ } catch (err) {
+ handler(err);
+ }
+ },
+ pasteSync: opts => {
+ try {
+ return execa.sync('termux-clipboard-get', opts);
+ } catch (err) {
+ handler(err);
+ }
+ }
+};
diff --git a/node_modules/clipboardy/lib/windows.js b/node_modules/clipboardy/lib/windows.js
new file mode 100644
index 00000000..d8f22941
--- /dev/null
+++ b/node_modules/clipboardy/lib/windows.js
@@ -0,0 +1,16 @@
+'use strict';
+const path = require('path');
+const execa = require('execa');
+const arch = require('arch');
+
+// Binaries from: https://github.com/sindresorhus/win-clipboard
+const winBinPath = arch() === 'x64' ?
+ path.join(__dirname, '../fallbacks/windows/clipboard_x86_64.exe') :
+ path.join(__dirname, '../fallbacks/windows/clipboard_i686.exe');
+
+module.exports = {
+ copy: opts => execa(winBinPath, ['--copy'], opts),
+ paste: opts => execa.stdout(winBinPath, ['--paste'], opts),
+ copySync: opts => execa.sync(winBinPath, ['--copy'], opts),
+ pasteSync: opts => execa.sync(winBinPath, ['--paste'], opts)
+};