Security update to Drupal 8.4.6
[yaffs-website] / node_modules / find-versions / cli.js
1 #!/usr/bin/env node
2 'use strict';
3 var getStdin = require('get-stdin');
4 var meow = require('meow');
5 var findVersions = require('./');
6
7 var cli = meow([
8         'Usage',
9         '  $ find-versions <string> [--first] [--loose]',
10         '  $ echo <string> | find-versions',
11         '',
12         'Example',
13         '  $ find-versions \'unicorns v1.2.3\'',
14         '  1.2.3',
15         '',
16         '  $ curl --version | find-versions --first',
17         '  7.30.0',
18         '',
19         'Options',
20         '  --first  Return the first match',
21         '  --loose  Match non-semver versions like 1.88'
22 ]);
23
24 function init(data) {
25         var ret = findVersions(data, {loose: cli.flags.loose});
26         console.log(cli.flags.first ? ret[0] : ret.join('\n'));
27 }
28
29 if (process.stdin.isTTY) {
30         if (!cli.input[0]) {
31                 console.error('Expected a string');
32                 process.exit(1);
33         }
34
35         init(cli.input[0]);
36 } else {
37         getStdin(init);
38 }