bin-version-check
Advanced tools
Comparing version 3.0.0 to 4.0.0
16
index.js
@@ -6,5 +6,5 @@ 'use strict'; | ||
module.exports = (bin, semverRange, opts) => { | ||
if (typeof bin !== 'string' || typeof semverRange !== 'string') { | ||
return Promise.reject('`binary` and `semverRange` required'); | ||
module.exports = (binary, semverRange, options) => { | ||
if (typeof binary !== 'string' || typeof semverRange !== 'string') { | ||
return Promise.reject(new Error('`binary` and `semverRange` arguments required')); | ||
} | ||
@@ -16,9 +16,9 @@ | ||
return binVersion(bin, opts).then(binVersion => { | ||
if (!semver.satisfies(semverTruncate(binVersion, 'patch'), semverRange)) { | ||
const err = new Error(`${bin} ${binVersion} doesn't satisfy the version requirement of ${semverRange}`); | ||
err.name = 'InvalidBinVersion'; | ||
throw err; | ||
return binVersion(binary, options).then(binaryVersion => { | ||
if (!semver.satisfies(semverTruncate(binaryVersion, 'patch'), semverRange)) { | ||
const error = new Error(`${binary} ${binaryVersion} doesn't satisfy the version requirement of ${semverRange}`); | ||
error.name = 'InvalidBinaryVersion'; | ||
throw error; | ||
} | ||
}); | ||
}; |
{ | ||
"name": "bin-version-check", | ||
"version": "3.0.0", | ||
"description": "Check whether a binary version satisfies a semver range", | ||
"license": "MIT", | ||
"repository": "sindresorhus/bin-version-check", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"cli", | ||
"bin", | ||
"binary", | ||
"executable", | ||
"version", | ||
"semver", | ||
"semantic", | ||
"range", | ||
"satisfy", | ||
"check", | ||
"validate" | ||
], | ||
"dependencies": { | ||
"bin-version": "^2.0.0", | ||
"semver": "^5.1.0", | ||
"semver-truncate": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "bin-version-check", | ||
"version": "4.0.0", | ||
"description": "Check whether a binary version satisfies a semver range", | ||
"license": "MIT", | ||
"repository": "sindresorhus/bin-version-check", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"cli", | ||
"bin", | ||
"binary", | ||
"executable", | ||
"version", | ||
"semver", | ||
"semantic", | ||
"range", | ||
"satisfy", | ||
"check", | ||
"validate" | ||
], | ||
"dependencies": { | ||
"bin-version": "^3.0.0", | ||
"semver": "^5.6.0", | ||
"semver-truncate": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.0.0-rc.1", | ||
"xo": "^0.23.0" | ||
} | ||
} |
@@ -11,3 +11,3 @@ # bin-version-check [![Build Status](https://travis-ci.org/sindresorhus/bin-version-check.svg?branch=master)](https://travis-ci.org/sindresorhus/bin-version-check) | ||
``` | ||
$ npm install --save bin-version-check | ||
$ npm install bin-version-check | ||
``` | ||
@@ -26,6 +26,10 @@ | ||
binVersionCheck('curl', '>=8').catch(err => { | ||
throw err; | ||
(async () => { | ||
try { | ||
await binVersionCheck('curl', '>=8'); | ||
} catch (error) { | ||
console.log(error); | ||
//=> 'InvalidBinVersion: curl 7.30.0 doesn't satisfy the version requirement of >=8' | ||
}); | ||
} | ||
})(); | ||
``` | ||
@@ -52,5 +56,7 @@ | ||
Type: `Object` | ||
##### args | ||
Type: `array` | ||
Type: `string[]` | ||
Default: `['--version']` | ||
@@ -68,2 +74,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
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
3920
72
+ Addedbin-version@3.1.0(transitive)
+ Addedcross-spawn@6.0.5(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexeca@1.0.0(transitive)
+ Addedfind-versions@3.2.0(transitive)
+ Addedget-stream@4.1.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedsemver-regex@2.0.0(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removedbin-version@2.0.0(transitive)
- Removedcross-spawn-async@2.2.5(transitive)
- Removedexeca@0.1.1(transitive)
- Removedfind-versions@2.0.0(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedsemver-regex@1.0.0(transitive)
- Removedyallist@2.1.2(transitive)
Updatedbin-version@^3.0.0
Updatedsemver@^5.6.0
Updatedsemver-truncate@^1.1.2