| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | declare namespace binVersion { |
| 2 | interface Options { |
| 3 | /** |
| 4 | The arguments to pass to `binary` so that it will print its version. |
| 5 | |
| 6 | @default ['--version'] |
| 7 | */ |
| 8 | args?: string[]; |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | Get the version of a binary in [semver](https://github.com/npm/node-semver) format. |
| 14 | |
| 15 | @param binary - The name of or path to the binary to get the version from. |
| 16 | @returns The version of the `binary`. |
| 17 | |
| 18 | @example |
| 19 | ``` |
| 20 | import binVersion = require('bin-version'); |
| 21 | |
| 22 | (async () => { |
| 23 | // $ curl --version |
| 24 | // curl 7.30.0 (x86_64-apple-darwin13.0) |
| 25 | |
| 26 | console.log(await binVersion('curl')); |
| 27 | //=> '7.30.0' |
| 28 | |
| 29 | |
| 30 | // $ openssl version |
| 31 | // OpenSSL 1.0.2d 9 Jul 2015 |
| 32 | |
| 33 | console.log(await binVersion('openssl', {args: ['version']})); |
| 34 | //=> '1.0.2' |
| 35 | })(); |
| 36 | ``` |
| 37 | */ |
| 38 | declare function binVersion( |
| 39 | binary: string, |
| 40 | options?: binVersion.Options |
| 41 | ): Promise<string>; |
| 42 | |
| 43 | export = binVersion; |