-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitkit.js
More file actions
38 lines (32 loc) · 782 Bytes
/
Copy pathgitkit.js
File metadata and controls
38 lines (32 loc) · 782 Bytes
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
import Octokit from '@octokit/rest'
const GITHUB_PAT = process.env.GITHUB_PAT
/**
* @module gitkit
*/
/**
* The Gitkit class
* @class
*/
class Gitkit {
/**
* Create an instance of Gitkit class
*
* @param {Object} config the gitkit config options
* @param {String} config.auth the personal access token
*/
constructor (conf) {
this.gitkit = Octokit(Object.assign({}, { auth: GITHUB_PAT }, conf))
}
/**
* Create issue if not already created
*
* @param {Object} obj the issue object object
* @returns {Number} The issue number which is created or to be assigned
*/
async createIssue (obj) {
return (await this.gitkit.issues.create(obj)).number
}
}
const gitkit = new Gitkit()
export { Gitkit, gitkit }
export default gitkit