Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clipboardy

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipboardy - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

fallbacks/linux/xsel

86

index.js
'use strict';
const path = require('path');
const execa = require('execa');
const termux = require('./lib/termux.js');
const linux = require('./lib/linux.js');
const macos = require('./lib/macos.js');
const windows = require('./lib/windows.js');
const handler = err => {
if (err.code === 'ENOENT') {
let message = 'Couldn\'t find the required `xsel` binary. On Debian/Ubuntu you can install it with: sudo apt install xsel';
if (err.path === 'termux-clipboard-get' || err.path === 'termux-clipboard-set') {
message = 'Couldn\'t find the termux-api scripts. You can install them with: apt install termux-api';
}
throw new Error(message);
}
throw err;
};
const darwin = {
copy: opts => execa('pbcopy', opts),
paste: opts => execa.stdout('pbpaste', opts),
copySync: opts => execa.sync('pbcopy', opts),
pasteSync: opts => execa.sync('pbpaste', opts)
};
// Binaries from: https://github.com/sindresorhus/win-clipboard
const winReadBinPath = path.join(__dirname, 'fallbacks/win/paste.exe');
const winWriteBinPath = path.join(__dirname, 'fallbacks/win/copy.exe');
const win32 = {
copy: opts => {
const input = opts.input;
delete opts.input;
return execa(winWriteBinPath, [input], opts);
},
paste: opts => execa.stdout(winReadBinPath, opts),
copySync: opts => {
const input = opts.input;
delete opts.input;
return execa.sync(winWriteBinPath, [input], opts);
},
pasteSync: opts => execa.sync(winReadBinPath, opts)
};
const xsel = path.join(__dirname, 'vendor/xsel');
const linux = {
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);
}
}
}
};
function platform() {
switch (process.platform) {
case 'darwin':
return darwin;
return macos;
case 'win32':
return win32;
return windows;
case 'android':

@@ -91,3 +17,3 @@ if (process.env.PREFIX !== '/data/data/com.termux/files/usr') {

}
return termux(handler);
return termux;
default:

@@ -94,0 +20,0 @@ return linux;

'use strict';
const execa = require('execa');
module.exports = handler => {
return {
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);
}
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);
}
}
};
{
"name": "clipboardy",
"version": "1.1.1",
"version": "1.1.2",
"description": "Access the system clipboard (copy/paste)",

@@ -21,4 +21,3 @@ "license": "MIT",

"lib",
"fallbacks",
"vendor"
"fallbacks"
],

@@ -25,0 +24,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc