From 6ad141834c4682cdec327c8cfee1822efb4f09be Mon Sep 17 00:00:00 2001 From: Ross Brodbeck Date: Tue, 26 Nov 2019 10:30:19 -0500 Subject: [PATCH] Update style --- packages/github/src/github.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/github/src/github.ts b/packages/github/src/github.ts index a7804a3505..2edb93bb63 100644 --- a/packages/github/src/github.ts +++ b/packages/github/src/github.ts @@ -1,21 +1,27 @@ // Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts import {graphql} from '@octokit/graphql' + +// we need this type to set up a property on the GitHub object +// that has token authorization +// (it is not exported from oktokit by default) import {graphql as GraphQL} from '@octokit/graphql/dist-types/types' + import Octokit from '@octokit/rest' -import * as Context from './context' +import * as Context from './context'; // We need this in order to extend Octokit -Octokit.prototype = new Octokit() +Octokit.prototype = new Octokit(); -export const context = new Context.Context() +export const context = new Context.Context(); export class GitHub extends Octokit { - graphql: GraphQL + public graphql: GraphQL; + constructor(token: string, opts: Omit = {}) { - super({...opts, auth: `token ${token}`}) + super({...opts, auth: `token ${token}`}); this.graphql = graphql.defaults({ headers: {authorization: `token ${token}`} - }) + }); } }