Skip to content

Commit

Permalink
Merge pull request #100 from Orbs/master
Browse files Browse the repository at this point in the history
Switch to using mikeal/request to gain proxy support
  • Loading branch information
guybedford committed Aug 19, 2014
2 parents 5b69d6f + c5afe46 commit 3c12876
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
8 changes: 7 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,13 @@ exports.set = function(name, val) {
config[part] = typeof config[part] == 'object' ? config[part] : {};
config = config[part];
}
config[nameParts[0]] = val;
if (val) {
config[nameParts[0]] = val;
}
else {
// If no value is specified, then remove property from config
delete config[nameParts[0]];
}

saveGlobalConfig();
}
13 changes: 6 additions & 7 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var pkg = require('./package');
var build = require('./build');
var Package = pkg.Package;

var https = require('https');
var request = require('request');

var fs = require('graceful-fs');
var mkdirp = require('mkdirp');
Expand Down Expand Up @@ -761,7 +761,7 @@ exports.checkDlLoader = function() {
});
}

var ghh = 'raw.githubusercontent.com';
var ghh = 'https://raw.githubusercontent.com';
var loaderVersions = ['0.8', '0.8', '0.0.58'];
exports.dlLoader = function(unminified, edge) {
var min = unminified ? '' : '.min';
Expand Down Expand Up @@ -807,14 +807,13 @@ exports.dlLoader = function(unminified, edge) {
return Promise.all(Object.keys(downloadFiles).map(function(url) {
var filename = downloadFiles[url];
return new Promise(function(resolve, reject) {
https.get({
agent: false,
hostname: ghh,
path: url,
request({
method: 'get',
url: ghh+url,
headers: {
'user-agent': 'jspm'
}
}, function(res) {
}, function(err, res) {
if (res.statusCode != 200)
return reject('Request error ' + res.statusCode + ' for ' + ghh + url);

Expand Down
24 changes: 11 additions & 13 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

var https = require('https');
var request = require('request');
var ui = require('./ui');
var semver = require('./semver');
var nodeSemver = require('semver');
Expand All @@ -23,7 +23,6 @@ var build = require('./build');
var config = require('./config');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');

var path = require('path');

var fs = require('graceful-fs');
Expand Down Expand Up @@ -134,12 +133,12 @@ exports.locate = function(target) {

return new Promise(function(resolve, reject) {
var resData = [];
https.get({
hostname: 'registry.jspm.io',
path: '/' + target.exactName,
request({
method: 'get',
url: 'registry.jspm.io/' + target.exactName,
headers: { accept: 'application/json' },
rejectUnauthorized: false
}, function(res) {
}, function(err,res) {
res.on('data', function(chunk) { resData.push(chunk); });
res.on('end', function() {
var result = resData.join('');
Expand Down Expand Up @@ -270,25 +269,24 @@ exports.lookup = function(pkg) {
exports.checkOverride = function(fullName, cdn) {
var hostname, path;
if (!cdn) {
hostname = 'github.jspm.io';
hostname = 'https://github.jspm.io';
path = '/jspm/registry@master/package-overrides/' + fullName.replace(':', '/') + '.json';
}
else {
hostname = fullName.substr(0, fullName.indexOf(':')) + '.jspm.io';
hostname = 'https://'+fullName.substr(0, fullName.indexOf(':')) + '.jspm.io';
path = '/' + fullName.substr(fullName.indexOf(':') + 1) + '/package.json';
}

return new Promise(function(resolve, reject) {
https.get({
hostname: hostname,
path: path,
request({
method: 'get',
url: hostname + path,
rejectUnauthorized: false
}, function(res) {
}, function(err, res) {
if (res.statusCode == 404) {
res.socket.destroy();
return resolve();
}

if (res.statusCode != 200) {
res.socket.destroy();
return reject('Error requesting package.json');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"mkdirp": "~0.3.5",
"ncp": "~0.5.0",
"replacestream": "^0.1.3",
"request": "^2.40.0",
"rimraf": "~2.2.2",
"rsvp": "~3.0.3",
"semver": "~2.1.0",
Expand Down

0 comments on commit 3c12876

Please sign in to comment.