From be7d72f74e69d6317a69456b1ab5f93bfcbe257a Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 6 Sep 2016 12:08:47 -0400 Subject: [PATCH 1/2] whitespace --- github.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github.js b/github.js index decab50..037fbd9 100644 --- a/github.js +++ b/github.js @@ -420,14 +420,14 @@ GithubLocation.prototype = { + (showAuthCommand ? '\nTo resolve use %jspm registry config github% to configure the credentials, or update them in your ~/.netrc file.' : '')); apiWarned = true; } - + if (res.headers.status.match(/^401/)) return apiFailWarn('lack of authorization', true); if (res.headers.status.match(/^406/)) return apiFailWarn('insufficient permissions. Ensure you have public_repo access.'); if (res.headers['x-ratelimit-remaining'] == '0') { if (self.auth) - return apiFailWarn('the rate limit being reached, which will be reset in `' + + return apiFailWarn('the rate limit being reached, which will be reset in `' + Math.round((res.headers['x-ratelimit-reset'] * 1000 - new Date(res.headers.date).getTime()) / 60000) + ' minutes`.'); return apiFailWarn('the rate limit being reached.', true); } @@ -456,7 +456,7 @@ GithubLocation.prototype = { var self = this; - if ((packageConfig.dependencies || packageConfig.peerDependencies || packageConfig.optionalDependencies) && + if ((packageConfig.dependencies || packageConfig.peerDependencies || packageConfig.optionalDependencies) && !packageConfig.registry && (!packageConfig.jspm || !(packageConfig.jspm.dependencies || packageConfig.jspm.peerDependencies || packageConfig.jspm.optionalDependencies))) { var hasDependencies = false; for (var p in packageConfig.dependencies) From a67325a1cc8a1af70b4de0ba2c29fc0356c2915c Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 6 Sep 2016 11:03:34 -0400 Subject: [PATCH 2/2] Use the GitHub API for all operations Fixes #99. --- exec-git.js | 66 ---------------------------------------- github.js | 86 +++++++++++++++++++--------------------------------- test/pool.js | 35 --------------------- 3 files changed, 32 insertions(+), 155 deletions(-) delete mode 100644 exec-git.js delete mode 100644 test/pool.js diff --git a/exec-git.js b/exec-git.js deleted file mode 100644 index 1bd6edf..0000000 --- a/exec-git.js +++ /dev/null @@ -1,66 +0,0 @@ -var Promise = require('bluebird').Promise; -var exec = require('child_process').exec; -var os = require('os'); - -function Pool(count) { - this.count = count; - this.queue = []; - this.promises = new Array(count); -} - -/* Run the function immediately. */ -function run(pool, idx, executionFunction) { - var p = Promise.resolve() - .then(executionFunction) - .then(function() { - delete pool.promises[idx]; - var next = pool.queue.pop(); - if (next) - pool.execute(next); - }); - pool.promises[idx] = p; - return p; -} - -/* Defer function to run once all running and queued functions have run. */ -function enqueue(pool, executeFunction) { - return new Promise(function(resolve) { - pool.queue.push(function() { - return Promise.resolve().then(executeFunction).then(resolve); - }); - }); -} - -/* Take a function to execute within pool, and return promise delivering the functions - * result immediately once it is run. */ -Pool.prototype.execute = function(executionFunction) { - var idx = -1; - - for (var i=0; i