forked from yoshuawuyts/github-standard-labels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.js
executable file
·64 lines (52 loc) · 1.28 KB
/
bin.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
63
64
#!/usr/bin/env node
var minimist = require('minimist')
var ghauth = require('ghauth')
var githubStandardLabels = require('./')
var argv = minimist(process.argv.slice(2), {
boolean: [
'version',
'help'
]
})
var usage = `
Usage:
$ github-standard-labels <username> <project>
Commands:
<default> Create a set of labels for a project
Options:
-h, --help Print usage
-v, --version Print version
`
;(function main (argv) {
if (argv.h) {
return console.info(usage)
} else if (argv.v) {
return console.info('v' + require('./package.json').version)
} else {
var username = argv._[0]
var repo = argv._[1]
if (!username || !repo) {
console.error('username or repo missing')
process.exit(1)
}
label(username, repo)
}
})(argv)
function label (username, repo) {
var config = {
configName: 'github-standard-labels',
scopes: ['repo'],
note: 'This is for github-standard-labels'
}
ghauth(config, function (err, github) {
if (err) throw err
var opts = {}
opts.username = username
opts.github = github
opts.repo = repo
githubStandardLabels(opts, function (err) {
if (err) throw err
console.info('Labels successfully applied to ' + username + '/' + repo)
})
})
}