Use the NPM-configured HTTPS proxy, if present

This commit is contained in:
Lovell Fuller 2015-12-03 21:30:47 +00:00
parent be381e4440
commit 16e0d54b15

View File

@ -77,7 +77,14 @@ module.exports.download_vips = function() {
var tmpFile = fs.createWriteStream(tarPath).on('finish', function() {
unpack(tarPath);
});
request(distBaseUrl + tarFilename).on('response', function(response) {
var options = {
url: distBaseUrl + tarFilename
};
if (process.env.npm_config_https_proxy) {
// Use the NPM-configured HTTPS proxy
options.proxy = process.env.npm_config_https_proxy;
}
request(options).on('response', function(response) {
if (response.statusCode !== 200) {
error(distBaseUrl + tarFilename + ' status code ' + response.statusCode);
}