UNPKG

565 BPlain TextView Raw
1import path from 'path';
2import fs from 'fs';
3import minimist from 'minimist';
4import getURL from './index';
5
6/* eslint no-sync:0 no-console:0 */
7const usage = fs.readFileSync(path.resolve(__dirname, '../usage.txt'), 'utf8');
8const args = minimist(process.argv.slice(2), {
9 boolean: ['debug']
10});
11
12args.version = args._[0] || args.version || 'stable';
13
14if (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}