Skip to content

Commit 42f5ade

Browse files
committed
fix(proxy): Support HTTP_PROXY and HTTPS_PROXY environment variables for install and search commands - fixes #81
1 parent 5b15523 commit 42f5ade

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

lib/install.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
var Promise = require('bluebird')
2-
, path = require('path')
3-
, _ = require('lodash')
4-
, https = require('follow-redirects').https
5-
, async = require('async')
6-
, utils = GLOBAL.lib.utils
7-
, search = GLOBAL.lib.search
8-
, packages = GLOBAL.lib.packages
9-
, util = GLOBAL.lib.util;
1+
var Promise = require('bluebird')
2+
, path = require('path')
3+
, _ = require('lodash')
4+
, https = require('follow-redirects').https
5+
, proxyAgent = require('https-proxy-agent')
6+
, async = require('async')
7+
, utils = GLOBAL.lib.utils
8+
, search = GLOBAL.lib.search
9+
, packages = GLOBAL.lib.packages
10+
, util = GLOBAL.lib.util;
1011

1112
/**
1213
* Launches the installation process
@@ -173,6 +174,12 @@ exports.run = function(args) {
173174
* @public
174175
*/
175176
exports.getJSON = function(options) {
177+
// Handle HTTP_PROXY and HTTPS_PROXY environment variables
178+
var proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || null;
179+
if (proxy !== null) {
180+
options.agent = new proxyAgent(proxy);
181+
}
182+
176183
return new Promise(function(resolve) {
177184
var req = https.request(options, function(res) {
178185
res.setEncoding('utf-8');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name" : "cleverstack-cli",
33
"description" : "Command line interface for CleverStack",
4-
"version" : "1.2.9",
4+
"version" : "1.2.10",
55
"license" : "MIT",
66
"author": {
77
"name" : "CleverStack",

0 commit comments

Comments
 (0)