Socket
Socket
Sign inDemoInstall

bin-version

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bin-version - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

22

index.js
'use strict';
var childProcess = require('child_process');
var findVersions = require('find-versions');
const execa = require('execa');
const findVersions = require('find-versions');
module.exports = function (bin, cb) {
childProcess.exec(bin + ' --version', function (err, stdout, stderr) {
if (err) {
module.exports = (bin, opts) => {
opts = opts || {};
return execa(bin, opts.args || ['--version'])
.then(result => findVersions(result.stdout || result.stderr, {loose: true})[0])
.catch(err => {
if (err.code === 'ENOENT') {
err.message = 'Couldn\'t find the `' + bin + '` binary. Make sure it\'s installed and in your $PATH';
err.message = `Couldn't find the '${bin}' binary. Make sure it's installed and in your $PATH`;
}
return cb(err);
}
cb(null, findVersions(stdout.trim() || stderr.trim(), {loose: true})[0]);
});
throw err;
});
};
{
"name": "bin-version",
"version": "1.0.4",
"version": "2.0.0",
"description": "Get the version of a binary in semver format",

@@ -10,9 +10,9 @@ "license": "MIT",

"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "node test.js"
"test": "xo && ava"
},

@@ -32,7 +32,12 @@ "files": [

"dependencies": {
"find-versions": "^1.0.0"
"execa": "^0.1.1",
"find-versions": "^2.0.0"
},
"devDependencies": {
"ava": "0.0.4"
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
}

@@ -8,3 +8,3 @@ # bin-version [![Build Status](https://travis-ci.org/sindresorhus/bin-version.svg?branch=master)](https://travis-ci.org/sindresorhus/bin-version)

```sh
```
$ npm install --save bin-version

@@ -16,3 +16,3 @@ ```

```sh
```
$ curl --version

@@ -23,11 +23,23 @@ curl 7.30.0 (x86_64-apple-darwin13.0)

```js
var binVersion = require('bin-version');
const binVersion = require('bin-version');
binVersion('curl', function (err, version) {
binVersion('curl').then(version => {
console.log(version);
//=> 7.30.0
//=> '7.30.0'
});
```
```
$ openssl version
OpenSSL 1.0.2d 9 Jul 2015
```
```js
binVersion('openssl', {args: ['version']}).then(version => {
console.log(version);
//=> '1.0.2'
});
```
## CLI

@@ -34,0 +46,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