forked from npm/gh-issues
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.js
36 lines (33 loc) · 913 Bytes
/
list.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
'use strict'
const github = require('./github.js')
const fs = require('fs')
const issueList = fs.createWriteStream('issue-list.ndjson')
const prList = fs.createWriteStream('pr-list.ndjson')
require('./app.js')(main)
function closeStream (stream) {
return new Promise((resolve, reject) => {
stream.on('error', reject)
stream.on('close', resolve)
})
}
async function main () {
github.paginate(github.rest.issues.listForRepo, {
owner: 'SocialStrata',
repo: 'crowdstack-pro',
state: 'open',
assignee: 'none',
per_page: 100
})
.then((issues) => {
issues.forEach(issue => {
if (issue.pull_request) {
prList.write(JSON.stringify(issue) + '\n')
} else {
issueList.write(JSON.stringify(issue) + '\n')
}
})
prList.end()
issueList.end()
})
.then(Promise.all([closeStream(prList), closeStream(issueList)]));
}