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

clipboardy

Package Overview
Dependencies
Maintainers
1
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 0.1.2 to 1.0.0

vendor/xsel

106

index.js
'use strict';
const execa = require('execa');
const writeCmd = () => {
switch (process.platform) {
case 'darwin':
return ['pbcopy'];
case 'win32':
return ['clip'];
default:
return ['xsel', '--clipboard', '--input'];
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 readCmd = () => {
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)
};
const win32 = {
copy: opts => execa('clip', [], opts),
paste: opts => execa.stdout('cscript', ['/Nologo', '.\\fallbacks\\win-read.vbs'], opts),
copySync: opts => execa.sync('clip', [], opts),
pasteSync: opts => execa.sync('cscript', ['/Nologo', '.\\fallbacks\\win-read.vbs'], opts)
};
const linux = {
copy: opts => {
return execa('./vendor/xsel', ['--clipboard', '--input'], opts)
.catch(() => execa('xsel', ['--clipboard', '--input'], opts))
.catch(handler);
},
paste: opts => {
return execa.stdout('./vendor/xsel', ['--clipboard', '--output'], opts)
.catch(() => execa.stdout('xsel', ['--clipboard', '--output'], opts))
.catch(handler);
},
copySync: opts => {
try {
return execa.sync('./vendor/xsel', ['--clipboard', '--input'], opts);
} catch (err) {
try {
return execa.sync('xsel', ['--clipboard', '--input'], opts);
} catch (err) {
handler(err);
}
}
},
pasteSync: opts => {
try {
return execa.sync('./vendor/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 ['pbpaste'];
return darwin;
case 'win32':
return ['cscript', '/Nologo', '.\\fallbacks\\win-read.vbs'];
return win32;
default:
return ['xsel', '--clipboard', '--output'];
return linux;
}
};
}
const handler = err => {
if (err.code === 'ENOENT' && process.platform !== 'darwin' && process.platform !== 'win32') {
throw new Error('Couldn\'t find the required `xsel` binary. On Debian/Ubuntu you can install it with: sudo apt install xsel');
}
throw err;
};
exports.write = input => {

@@ -39,10 +77,6 @@ if (typeof input !== 'string') {

const args = writeCmd();
return execa(args.shift(), args, {input}).then(() => {}).catch(handler);
return platform().copy({input}).then(() => {});
};
exports.read = () => {
const args = readCmd();
return execa.stdout(args.shift(), args).catch(handler);
};
exports.read = () => platform().paste();

@@ -54,19 +88,5 @@ exports.writeSync = input => {

const args = writeCmd();
const results = execa.sync(args.shift(), args, {input});
if (results.error) {
handler(results.error);
}
platform().copySync({input});
};
exports.readSync = () => {
const args = readCmd();
const results = execa.sync(args.shift(), args);
if (results.error) {
handler(results.error);
}
return results.stdout;
};
exports.readSync = () => platform().pasteSync().stdout;
{
"name": "clipboardy",
"version": "0.1.2",
"version": "1.0.0",
"description": "Access the system clipboard (copy/paste)",

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

"index.js",
"fallbacks"
"fallbacks",
"vendor"
],

@@ -37,3 +38,3 @@ "keywords": [

"dependencies": {
"execa": "^0.5.0"
"execa": "^0.6.0"
},

@@ -40,0 +41,0 @@ "devDependencies": {

@@ -14,5 +14,3 @@ # clipboardy [![Build Status: macOS & Linux](https://travis-ci.org/sindresorhus/clipboardy.svg?branch=master)](https://travis-ci.org/sindresorhus/clipboardy) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/gflt3gjn1ia0a3vo/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/clipboardy/branch/master)

*Linux users will probably have to install [xsel](https://linux.die.net/man/1/xsel): `sudo apt install xsel`*
## Usage

@@ -19,0 +17,0 @@

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