-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
62 lines (51 loc) · 1.62 KB
/
cli.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
/**
* is-missing <https://github.com/tunnckoCore/is-missing>
*
* Copyright (c) 2015 Charlike Mike Reagent, contributors.
* Released under the MIT license.
*/
'use strict'
var meow = require('meow')
var chalk = require('chalk')
var isMissing = require('./index')
var multiline = require('multiline')
var log = require('log-symbols')
var exit = process.exit
var cli = meow({
help: chalk.gray(multiline.stripIndent(function () { /*
Options
--help show this help
--version current version
--token github personal access token
Usage
is-missing [name]
Example
is-missing not-exisiting-npm-package-name
is-missing mochajs/mocha
is-missing micromatch
is-missing koa
*/}))
})
if (Array.isArray(cli.input) && !cli.input.length) {
console.error()
console.error(chalk.red(' Whoaaa!'))
console.error()
console.error(' %s %s', log.error, chalk.red('You should give a name or user/repo.'))
console.error(' %s %s', log.info, chalk.blue('Try to run:'), chalk.gray('is-missing mochajs/mocha'))
console.error()
exit(1)
}
console.log()
console.log(chalk.green(' Aloha, master! How r u today?'))
console.log()
var name = String(cli.input[0])
isMissing(name, cli.flags, function _cb (err, bool) { // eslint-disable-line handle-callback-err
var yes = chalk.gray('Oh yes, ' + chalk.bold(name) + ' will be yours.')
var doh = chalk.gray('Sorry, ' + chalk.bold(name) + ' already exists.')
var state = bool === true ? yes : doh
var icon = bool === true ? log.success : log.error
console.log(' %s %s', icon, state)
console.log()
exit(0)
})