├── .gitignore ├── .gitattributes ├── .travis.yml ├── test.js ├── .editorconfig ├── cli.js ├── package.json ├── license └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 'stable' 4 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import execa from 'execa'; 3 | 4 | test(async t => { 5 | await t.throws(execa('./cli.js', ['curl', '>=8']), /doesn't satisfy/); 6 | await t.throws(execa('./cli.js', ['openssl', '>=10', '--args=version']), /doesn't satisfy/); 7 | }); 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [{package.json,*.yml}] 11 | indent_style = space 12 | indent_size = 2 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | const meow = require('meow'); 4 | const arrify = require('arrify'); 5 | const fn = require('bin-version-check'); 6 | 7 | const cli = meow(` 8 | Usage 9 | $ bin-version-check 10 | 11 | Options 12 | --args CLI args to get binary version (Can be set multiple times) [Default: --version] 13 | 14 | Example 15 | $ curl --version 16 | curl 7.30.0 (x86_64-apple-darwin13.0) 17 | $ bin-version-check curl '>=8' 18 | curl 7.30.0 doesn't satisfy the version requirement of >=8 19 | 20 | Exits with code 0 if the semver range is satisfied and 1 if not 21 | `); 22 | 23 | if (cli.input.length === 0) { 24 | console.error('`binary` and `semver-range` required'); 25 | process.exit(1); 26 | } 27 | 28 | if (cli.flags.args) { 29 | cli.flags.args = arrify(cli.flags.args); 30 | } 31 | 32 | fn(cli.input[0], cli.input[1], cli.flags); 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bin-version-check-cli", 3 | "version": "1.0.0", 4 | "description": "Check whether a binary version satisfies a semver range", 5 | "license": "MIT", 6 | "repository": "sindresorhus/bin-version-check-cli", 7 | "author": { 8 | "name": "Sindre Sorhus", 9 | "email": "sindresorhus@gmail.com", 10 | "url": "sindresorhus.com" 11 | }, 12 | "bin": { 13 | "bin-version-check": "cli.js" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "scripts": { 19 | "test": "xo && ava" 20 | }, 21 | "files": [ 22 | "cli.js" 23 | ], 24 | "keywords": [ 25 | "cli-app", 26 | "cli", 27 | "binary", 28 | "executable", 29 | "version", 30 | "semver", 31 | "semantic", 32 | "range", 33 | "satisfy", 34 | "check", 35 | "validate" 36 | ], 37 | "dependencies": { 38 | "arrify": "^1.0.1", 39 | "bin-version-check": "^3.0.0", 40 | "meow": "^3.6.0" 41 | }, 42 | "devDependencies": { 43 | "ava": "*", 44 | "execa": "^0.1.1", 45 | "xo": "*" 46 | }, 47 | "xo": { 48 | "esnext": true 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Sindre Sorhus (sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # bin-version-check-cli [![Build Status](https://travis-ci.org/sindresorhus/bin-version-check-cli.svg?branch=master)](https://travis-ci.org/sindresorhus/bin-version-check-cli) 2 | 3 | > Check whether a binary version satisfies a [semver range](https://github.com/npm/node-semver#ranges) 4 | 5 | Useful when you have a thing that only works with specific versions of a binary. 6 | 7 | 8 | ## Install 9 | 10 | ``` 11 | $ npm install --global bin-version-check-cli 12 | ``` 13 | 14 | 15 | ## Usage 16 | 17 | ``` 18 | $ bin-version-check --help 19 | 20 | Usage 21 | $ bin-version-check 22 | 23 | Options 24 | --args CLI args to get binary version (Can be set multiple times) [Default: --version] 25 | 26 | Example 27 | $ curl --version 28 | curl 7.30.0 (x86_64-apple-darwin13.0) 29 | $ bin-version-check curl '>=8' 30 | curl 7.30.0 doesn't satisfy the version requirement of >=8 31 | 32 | Exits with code 0 if the semver range is satisfied and 1 if not 33 | ``` 34 | 35 | 36 | ## Related 37 | 38 | - [bin-version-check](https://github.com/sindresorhus/bin-version-check) - API for this module 39 | 40 | 41 | ## License 42 | 43 | MIT © [Sindre Sorhus](http://sindresorhus.com) 44 | --------------------------------------------------------------------------------