Skip to content

Commit

Permalink
better logic around the getIssue code
Browse files Browse the repository at this point in the history
  • Loading branch information
deecewan committed Mar 3, 2017
1 parent 341a346 commit 96a02e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions source/platforms/GitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class GitHub {

async getIssue(): Promise<GitHubIssue> {
const issue = await this.api.getIssue()
if (!issue) {
return { labels: [] }
}
const labels = issue.labels.map((label: any): GitHubIssueLabel => ({
id: label.id,
url: label.url,
Expand Down
8 changes: 6 additions & 2 deletions source/platforms/github/GitHubAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ export class GitHubAPI {
return []
}

getIssue(): Promise<any> {
async getIssue(): Promise<any> {
const repo = this.ciSource.repoSlug
const prID = this.ciSource.pullRequestID
return this.get(`repos/${repo}/issues/${prID}`)
const res = await this.get(`repos/${repo}/issues/${prID}`)
if (res.ok) {
return res.json()
}
return {}
}

private api(path: string, headers: any = {}, body: any = {}, method: string): Promise<any> {
Expand Down

0 comments on commit 96a02e8

Please sign in to comment.