From 8a3b646696655ac764e648622fcb51268b5d1ffd Mon Sep 17 00:00:00 2001 From: Anton Wilhelm Date: Sun, 21 Sep 2014 20:03:28 +0200 Subject: [PATCH] print more rate limit infos for github --- lib/remotes/github.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/remotes/github.js b/lib/remotes/github.js index ee62165..8c518a2 100644 --- a/lib/remotes/github.js +++ b/lib/remotes/github.js @@ -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.'); } }