forked from npm/gh-issues
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclose-issues.js
48 lines (45 loc) · 1.18 KB
/
close-issues.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
'use strict'
const fs = require('fs')
const { promisify } = require('util')
const readFile = promisify(fs.readFile)
const split = require('split')
const fun = require('funstream')
const github = require('./github.js')
function sleep (num) {
return new Promise((resolve) => {
setTimeout(resolve, num)
})
}
require('./app')(main)
async function main (args) {
if (args.length !== 2) {
console.error('close-issues <label> <messagefile> < issueids')
return
}
const [ label, messageFile ] = args
const message = await readFile(messageFile, 'utf8')
await fun(process.stdin).lines().filter(id => id !== '').map(id => Number(id)).forEach(async id => {
await github.issues.addLabels({
owner: 'SocialStrata',
repo: 'crowdstack-pro',
issue_number: id,
labels: [ label ]
})
await sleep(4000)
await github.issues.createComment({
owner: 'SocialStrata',
repo: 'crowdstack-pro',
issue_number: id,
body: message
})
await sleep(4000)
await github.issues.update({
owner: 'SocialStrata',
repo: 'crowdstack-pro',
issue_number: id,
state: 'closed',
})
console.log(id)
await sleep(4000)
})
}