forked from gavinr/github-csv-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.js
41 lines (40 loc) · 1.09 KB
/
helpers.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
const createIssue = (octokit, issueInfo, state = false) => {
return new Promise((resolve, reject) => {
octokit.issues.create(issueInfo).then(
(res) => {
// console.log("res", res);
if (res.status === 201) {
if (state === false) {
// Success creating the issue and we do not have to close the issue, so we're done.
resolve(res);
} else {
// need to close the issue!
const issueNumber = res.data.number;
octokit.issues
.update({
owner: issueInfo.owner,
repo: issueInfo.repo,
issue_number: issueNumber,
state,
})
.then(
(editRes) => {
resolve(editRes);
},
(err) => {
reject(err);
}
);
}
} else {
// error creating the issue
reject(res);
}
},
(err) => {
reject(err);
}
);
});
};
module.exports = { createIssue };