Socket
Socket
Sign inDemoInstall

bin-version-check

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bin-version-check - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

31

index.js

@@ -1,22 +0,23 @@

'use strict';
const semver = require('semver');
const binVersion = require('bin-version');
const semverTruncate = require('semver-truncate');
import semver from 'semver';
import binaryVersion from 'bin-version';
import semverTruncate from 'semver-truncate';
module.exports = (binary, semverRange, options) => {
export default async function binaryVersionCheck(binary, semverRange, options) {
if (typeof binary !== 'string' || typeof semverRange !== 'string') {
return Promise.reject(new Error('`binary` and `semverRange` arguments required'));
throw new TypeError('`binary` and `semverRange` arguments required');
}
if (!semver.validRange(semverRange)) {
return Promise.reject(new Error('Invalid version range'));
throw new Error('Invalid version range');
}
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;
}
});
};
const version = await binaryVersion(binary, options);
if (semver.satisfies(semverTruncate(version, 'patch'), semverRange)) {
return;
}
const error = new Error(`${binary} ${version} doesn't satisfy the version requirement of ${semverRange}`);
error.name = 'InvalidBinaryVersion';
throw error;
}
{
"name": "bin-version-check",
"version": "4.0.0",
"version": "5.0.0",
"description": "Check whether a binary version satisfies a semver range",
"license": "MIT",
"repository": "sindresorhus/bin-version-check",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=6"
"node": ">=12"
},

@@ -23,3 +26,2 @@ "scripts": {

"cli",
"bin",
"binary",

@@ -36,10 +38,10 @@ "executable",

"dependencies": {
"bin-version": "^3.0.0",
"semver": "^5.6.0",
"semver-truncate": "^1.1.2"
"bin-version": "^6.0.0",
"semver": "^7.3.5",
"semver-truncate": "^2.0.0"
},
"devDependencies": {
"ava": "^1.0.0-rc.1",
"xo": "^0.23.0"
"ava": "^3.15.0",
"xo": "^0.39.1"
}
}

@@ -1,2 +0,2 @@

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

@@ -7,3 +7,2 @@ > Check whether a binary version satisfies a [semver range](https://github.com/npm/node-semver#ranges)

## Install

@@ -15,3 +14,2 @@

## Usage

@@ -25,18 +23,15 @@

```js
const binVersionCheck = require('bin-version-check');
import binaryVersionCheck from 'bin-version-check';
(async () => {
try {
await binVersionCheck('curl', '>=8');
} catch (error) {
console.log(error);
//=> 'InvalidBinVersion: curl 7.30.0 doesn't satisfy the version requirement of >=8'
}
})();
try {
await binaryVersionCheck('curl', '>=8');
} catch (error) {
console.log(error);
//=> 'InvalidBinaryVersion: curl 7.30.0 doesn't satisfy the version requirement of >=8'
}
```
## API
### binVersionCheck(binary, semverRange, [options])
### binaryVersionCheck(binary, semverRange, options?)

@@ -57,7 +52,7 @@ #### binary

Type: `Object`
Type: `object`
##### args
Type: `string[]`
Type: `string[]`\
Default: `['--version']`

@@ -67,10 +62,4 @@

## Related
- [bin-version-check-cli](https://github.com/sindresorhus/bin-version-check-cli) - CLI for this module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

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