Skip to content

Commit

Permalink
Merge 1232ae4 into 0d03374
Browse files Browse the repository at this point in the history
  • Loading branch information
odykyi committed Aug 24, 2017
2 parents 0d03374 + 1232ae4 commit 9024f38
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/bower-config/lib/util/proxy.js
Expand Up @@ -4,27 +4,28 @@
var EnvProxy = function() {
this.restoreFrom = {};
};
var hasOwnProperty = Object.prototype.hasOwnProperty;

EnvProxy.prototype.set = function (config) {
this.config = config;

// Override environment defaults if proxy config options are set
// This will make requests.js follow the proxies in config
if (Object.prototype.hasOwnProperty.call(config, 'noProxy')) {
if (hasOwnProperty.call(config, 'noProxy')) {
this.restoreFrom.NO_PROXY = process.env.NO_PROXY;
this.restoreFrom.no_proxy = process.env.no_proxy;
delete process.env.no_proxy;
process.env.NO_PROXY = config.noProxy;
}

if (Object.prototype.hasOwnProperty.call(config, 'proxy')) {
if (hasOwnProperty.call(config, 'proxy')) {
this.restoreFrom.HTTP_PROXY = process.env.HTTP_PROXY;
this.restoreFrom.http_proxy = process.env.http_proxy;
delete process.env.http_proxy;
process.env.HTTP_PROXY = config.proxy;
}

if (Object.prototype.hasOwnProperty.call(config, 'httpsProxy')) {
if (hasOwnProperty.call(config, 'httpsProxy')) {
this.restoreFrom.HTTPS_PROXY = process.env.HTTPS_PROXY;
this.restoreFrom.https_proxy = process.env.https_proxy;
delete process.env.https_proxy;
Expand All @@ -33,7 +34,7 @@ EnvProxy.prototype.set = function (config) {
};

EnvProxy.prototype.restore = function () {
if (Object.prototype.hasOwnProperty.call(this.config, 'noProxy')) {
if (hasOwnProperty.call(this.config, 'noProxy')) {
if (this.restoreFrom.NO_PROXY !== undefined) {
process.env.NO_PROXY = this.restoreFrom.NO_PROXY;
} else {
Expand All @@ -47,7 +48,7 @@ EnvProxy.prototype.restore = function () {
}
}

if (Object.prototype.hasOwnProperty.call(this.config, 'proxy')) {
if (hasOwnProperty.call(this.config, 'proxy')) {
if (this.restoreFrom.HTTP_PROXY !== undefined) {
process.env.HTTP_PROXY = this.restoreFrom.HTTP_PROXY;
} else {
Expand All @@ -61,7 +62,7 @@ EnvProxy.prototype.restore = function () {
}
}

if (Object.prototype.hasOwnProperty.call(this.config, 'httpsProxy')) {
if (hasOwnProperty.call(this.config, 'httpsProxy')) {
if (this.restoreFrom.HTTPS_PROXY !== undefined) {
process.env.HTTPS_PROXY = this.restoreFrom.HTTPS_PROXY;
} else {
Expand Down

0 comments on commit 9024f38

Please sign in to comment.