UNPKG

777 BJavaScriptView Raw
1require('hard-rejection/register')
2const updateNotifier = require('update-notifier')
3const yargs = require('yargs')
4const {join} = require('path')
5const {fromUrl} = require('hosted-git-info')
6const readPkgUp = require('read-pkg-up')
7
8module.exports.cli = async () => {
9 const {pkg} = await readPkgUp({cwd: __dirname})
10 process.title = Object.keys(pkg.bin)[0]
11 updateNotifier({pkg}).notify()
12 await yargs
13 .usage('Usage: $0 <command>')
14 .example('$0 --help <command>', 'Show command-specific options')
15 .epilogue(`Documentation:\n ${fromUrl(pkg.repository.url).docs()}`)
16 .commandDir(join(__dirname, 'commands'))
17 .demandCommand(1)
18 .help('help').alias('h', 'help')
19 .version().alias('v', 'version')
20 .wrap(null)
21 .parse(process.argv.slice(2))
22}