-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·36 lines (30 loc) · 682 Bytes
/
cli.js
File metadata and controls
executable file
·36 lines (30 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
import meow from 'meow';
import latestVersion from 'latest-version';
const cli = meow(`
Usage
$ latest-version <package-name>
Options
--range Specify which semver range to use to find the latest version
Examples
$ latest-version ava
3.13.0
$ latest-version electron --range=beta
11.0.0-beta.11
`, {
importMeta: import.meta,
flags: {
range: {
type: 'string',
},
},
});
if (cli.input.length === 0) {
console.error('Please specify a package name');
process.exit(1);
}
(async () => {
const {range: version} = cli.flags;
const result = await latestVersion(cli.input[0], version ? {version} : {});
console.log(result);
})();