bin-version
Advanced tools
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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
3092
50
0
2
2
+ Addedexeca@^0.1.1
+ Addedcross-spawn-async@2.2.5(transitive)
+ Addedexeca@0.1.1(transitive)
+ Addedfind-versions@2.0.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedarray-find-index@1.0.2(transitive)
- Removedcamelcase@2.1.1(transitive)
- Removedcamelcase-keys@2.1.0(transitive)
- Removedcurrently-unhandled@0.4.1(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedfind-versions@1.2.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-stdin@4.0.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedindent-string@2.1.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-finite@1.1.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedloud-rejection@1.6.0(transitive)
- Removedmap-obj@1.0.1(transitive)
- Removedmeow@3.7.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedredent@1.0.0(transitive)
- Removedrepeating@2.0.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedstrip-indent@1.0.1(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtrim-newlines@1.0.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
Updatedfind-versions@^2.0.0