Add github package (#32)

* Add github package

* Docs

* Feedback

* Accidentally added extra

* Allow octokit to be extended

* Respond to feedback

* Feedback
This commit is contained in:
Danny McCormick
2019-07-29 13:09:32 -04:00
committed by GitHub
parent 4f5cf60872
commit 2a2b51f939
12 changed files with 5617 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
import {GraphQlQueryResponse, Variables, defaults} from '@octokit/graphql'
import Octokit from '@octokit/rest'
import * as Context from './context'
// We need this in order to extend Octokit
Octokit.prototype = new Octokit()
module.exports.context = new Context.Context()
export class GitHub extends Octokit {
graphql: (
query: string,
variables?: Variables
) => Promise<GraphQlQueryResponse>
constructor(token: string) {
super({auth: `token ${token}`})
this.graphql = defaults({
headers: {authorization: `token ${token}`}
})
}
}