Socket
Socket
Sign inDemoInstall

bin-check

Package Overview
Dependencies
52
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 3.0.0

26

index.js
'use strict';
var spawn = require('child_process').spawn;
var executable = require('executable');
var Promise = require('pinkie-promise');
module.exports = function (bin, cmd, cb) {
if (typeof cmd === 'function') {
cb = cmd;
module.exports = function (bin, cmd) {
if (!Array.isArray(cmd)) {
cmd = ['--help'];
}
executable(bin, function (err, works) {
if (err) {
cb(err);
return;
}
return executable(bin).then(function (works) {
if (!works) {
cb(new Error('Couldn\'t execute the `' + bin + '` binary. Make sure it has the right permissions.'));
return;
return Promise.reject(new Error('Couldn\'t execute the `' + bin + '` binary. Make sure it has the right permissions.'));
}
var cp = spawn(bin, cmd);
return new Promise(function (resolve, reject) {
var cp = spawn(bin, cmd);
cp.on('error', cb);
cp.on('exit', function (code) {
cb(null, code === 0);
cp.on('error', reject);
cp.on('exit', function (code) {
resolve(code === 0);
});
});
});
};
{
"name": "bin-check",
"version": "2.0.0",
"version": "3.0.0",
"description": "Check if a binary is working",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "node test/test.js"
"test": "xo && ava"
},

@@ -29,7 +29,14 @@ "files": [

"dependencies": {
"executable": "^1.0.0"
"executable": "^2.0.0",
"pinkie-promise": "^1.0.0"
},
"devDependencies": {
"ava": "^0.0.4"
"ava": "*",
"xo": "*"
},
"xo": {
"ignore": [
"test/test.js"
]
}
}

@@ -16,5 +16,5 @@ # bin-check [![Build Status](https://travis-ci.org/kevva/bin-check.svg?branch=master)](https://travis-ci.org/kevva/bin-check)

```js
var binCheck = require('bin-check');
const binCheck = require('bin-check');
binCheck('/bin/sh', ['--version'], function (err, works) {
binCheck('/bin/sh', ['--version']).then(works => {
console.log(works);

@@ -28,6 +28,9 @@ //=> true

### binCheck(binary, command, callback)
### binCheck(binary, [command])
Returns a promise that resolves to a `boolean`.
#### binary
*Required*
Type: `string`

@@ -44,11 +47,5 @@

#### callback(err, works)
Type: `function`
`works` is a `boolean` which returns `true` if the binary is working correctly.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc