1 | import path from 'path';
|
2 | import fs from 'fs';
|
3 | import minimist from 'minimist';
|
4 | import getURL from './index';
|
5 |
|
6 |
|
7 | const usage = fs.readFileSync(path.resolve(__dirname, '../usage.txt'), 'utf8');
|
8 | const args = minimist(process.argv.slice(2), {
|
9 | boolean: ['debug']
|
10 | });
|
11 |
|
12 | args.version = args._[0] || args.version || 'stable';
|
13 |
|
14 | if (args.help || args.h) {
|
15 | console.error(usage);
|
16 | process.exitCode = 1;
|
17 | } else {
|
18 | getURL(args as any)
|
19 | .then(pkg => console.log(pkg.url))
|
20 | .catch(err => { process.nextTick(() => { throw err; }); });
|
21 | }
|