Skip to content

Commit

Permalink
print more rate limit infos for github
Browse files Browse the repository at this point in the history
  • Loading branch information
timaschew committed Sep 21, 2014
1 parent 3ebd488 commit 8a3b646
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/remotes/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,14 @@ function errorRateLimitExceeded(res) {
*/

function checkRateLimitRemaining(res) {
var limit = parseInt(res.headers['x-ratelimit-limit'], 10);
var remaining = parseInt(res.headers['x-ratelimit-remaining'], 10);
if (remaining <= 50) {
console.warn('github remote: only %d requests remaining.', remaining);
var reset = parseInt(res.headers['x-ratelimit-reset'], 10);
var resetDate = new Date(reset * 1000);
if (remaining <= 60) {
// either the user reach almost his 5000/hour limit
// or he doesn't use github authentication
console.warn('github remote: %d of %d requests remaining, resetting at %s', remaining, limit, resetDate);
console.warn('github remote: see https://github.com/component/guide/blob/master/changelogs/1.0.0.md#required-authentication for more information.');
}
}
Expand Down

0 comments on commit 8a3b646

Please sign in to comment.