diff --git a/lib/core/package.js b/lib/core/package.js index 231f4b41..504abc7b 100644 --- a/lib/core/package.js +++ b/lib/core/package.js @@ -193,6 +193,11 @@ Package.prototype.download = function () { var src = url.parse(this.assetUrl); var req = src.protocol === 'https:' ? https : http; + if (process.env.HTTP_PROXY) { + src = url.parse(process.env.HTTP_PROXY); + src.path = this.assetUrl; + } + tmp.dir(function (err, tmpPath) { var file = fs.createWriteStream(path.join((this.path = tmpPath), 'index' + this.assetType)); @@ -293,7 +298,11 @@ Package.prototype.cache = function () { return this.emit('cache'); } template('action', { name: 'caching', shizzle: this.gitUrl }).on('data', this.emit.bind(this, 'data')); - var cp = spawn('git', ['clone', this.gitUrl, this.path]); + var url = this.gitUrl; + if (process.env.HTTP_PROXY) { + url = url.replace(/^git:/, 'https:'); + } + var cp = spawn('git', ['clone', url, this.path]); cp.stderr.setEncoding('utf8'); cp.stderr.on('data', this.emit.bind(this, 'data')); cp.on('close', function (code) { @@ -413,4 +422,4 @@ Package.prototype.__defineGetter__('localPath', function () { return path.join(process.cwd(), config.directory, this.name); }); -module.exports = Package; \ No newline at end of file +module.exports = Package; diff --git a/lib/core/source.js b/lib/core/source.js index 75162cf8..9f1ace85 100644 --- a/lib/core/source.js +++ b/lib/core/source.js @@ -11,6 +11,10 @@ var _ = require('lodash'); var endpoint = 'https://bower.herokuapp.com/packages'; +if (process.env.HTTP_PROXY) { + request = request.defaults({'proxy': process.env.HTTP_PROXY}); +} + exports.lookup = function (name, callback) { request.get(endpoint + '/' + encodeURIComponent(name), function (err, response, body) { if (err || response.statusCode !== 200) return callback(err || new Error(name + ' not found')); @@ -65,4 +69,4 @@ exports.all = function (callback) { request.get(endpoint, function (err, response, body) { callback(err, body && JSON.parse(body)); }); -}; \ No newline at end of file +};