You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # bin-version-check [![Build Status](https://travis-ci.org/sindresorhus/bin-version-check.svg?branch=master)](https://travis-ci.org/sindresorhus/bin-version-check)
  2. > Check whether a binary version satisfies a [semver range](https://github.com/npm/node-semver#ranges)
  3. Useful when you have a thing that only works with specific versions of a binary.
  4. ## Install
  5. ```
  6. $ npm install bin-version-check
  7. ```
  8. ## Usage
  9. ```
  10. $ curl --version
  11. curl 7.30.0 (x86_64-apple-darwin13.0)
  12. ```
  13. ```js
  14. const binVersionCheck = require('bin-version-check');
  15. (async () => {
  16. try {
  17. await binVersionCheck('curl', '>=8');
  18. } catch (error) {
  19. console.log(error);
  20. //=> 'InvalidBinVersion: curl 7.30.0 doesn't satisfy the version requirement of >=8'
  21. }
  22. })();
  23. ```
  24. ## API
  25. ### binVersionCheck(binary, semverRange, [options])
  26. #### binary
  27. Type: `string`
  28. Name or path of the binary to check.
  29. #### semverRange
  30. Type: `string`
  31. [Semver range](https://github.com/npm/node-semver#ranges) to check against.
  32. #### options
  33. Type: `Object`
  34. ##### args
  35. Type: `string[]`
  36. Default: `['--version']`
  37. CLI arguments used to get the binary version.
  38. ## Related
  39. - [bin-version-check-cli](https://github.com/sindresorhus/bin-version-check-cli) - CLI for this module
  40. ## License
  41. MIT © [Sindre Sorhus](https://sindresorhus.com)