Skip to content

Commit

Permalink
use Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
loddit committed Aug 16, 2015
1 parent 1126e61 commit d035a2d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions legilimens.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ getClosedPullRequestsAfter = (time) ->
new Date(pullRequest.merged_at) > time
printPullRequestsReport(pullRequests)

getLastedReleaseTime = (callback) ->
getLastedReleaseTime = new Promise (resolve, reject) ->
callGithubAPI (repoUrl + LATEST_RELEASE_PATH), (error, response, body) ->
if (!error and response.statusCode isnt 200)
console.log error, body
reject error
else
lastedReleaseTime = new Date(JSON.parse(body).created_at)
console.log lastedReleaseTime
callback(lastedReleaseTime)
resolve(lastedReleaseTime)

printPullRequestsReport = (pullRequests) ->
index = 1
pullRequests.forEach (pullRequest) ->
console.log "#{index}. #{pullRequest.title} by @#{pullRequest.user.login}"
index++

getLastedReleaseTime(getClosedPullRequestsAfter)
getLastedReleaseTime.then getClosedPullRequestsAfter

0 comments on commit d035a2d

Please sign in to comment.