blob: 00287aec2c658069667c59f16bcd6b0dbabc5eb1 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001declare 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/**
13Get 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```
20import 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*/
38declare function binVersion(
39 binary: string,
40 options?: binVersion.Options
41): Promise<string>;
42
43export = binVersion;