-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
36 lines (28 loc) · 1 KB
/
index.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
const GitHub = require('github-api')
const config = require("./config.json")
const labelsFile = require("./labels.json")
const gh = new GitHub({ token: config.token })
const me = gh.getUser()
const main = async () => {
const { data: user } = await me.getProfile()
console.log(`👋🏻 Welcome ${user.name} !`, `\n`)
const remoteIssues = gh.getIssues(config.username, config.repository)
// delete labels
const { data: labels } = await remoteIssues.listLabels()
await Promise.all(labels.map(label => remoteIssues.deleteLabel(label.name)))
console.log(`✅ Labels par défaut supprimé !`)
// add new labels
remoteIssues.createLabel({name: 'test'})
.then(({ data: _createdLabel }) => {
for (let i = 0; i < labelsFile.length; i++) {
let labelsExample = {
name: labelsFile[i].name,
color: labelsFile[i].color,
}
remoteIssues.createLabel(labelsExample)
}
console.log(`✅ Nouveaux Labels ajoutés`)
})
.then(() => remoteIssues.deleteLabel('test'))
}
main()