Skip to content

Commit 5b15523

Browse files
committed
fix(proxy): Support proxies fixes #81
1 parent b2bdc3f commit 5b15523

3 files changed

Lines changed: 22 additions & 15 deletions

File tree

bin/clever

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async.waterfall(
3535
});
3636

3737
// Only check for updates on a set interval
38-
if (Date.now() - updateConfig.get('lastUpdateCheck') > checkUpdatesEvery) {
38+
if (!process.env.HTTP_PROXY && !process.env.HTTPS_PROXY && Date.now() - updateConfig.get('lastUpdateCheck') > checkUpdatesEvery) {
3939
notifier = updateNotifier({ pkg: packageJson, callback: checkDone });
4040
} else {
4141
checkDone(null);

lib/packages.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
var Promise = require('bluebird')
2-
, zlib = require('zlib')
3-
, async = require('async')
4-
, path = require('path')
5-
, fs = require('fs')
6-
, ncp = require('ncp')
7-
, rimraf = require('rimraf')
8-
, tar = require('tar')
9-
, _url = require('url')
10-
, https = require('follow-redirects').https
11-
, project = GLOBAL.lib.project
12-
, utils = GLOBAL.lib.utils;
1+
var Promise = require('bluebird')
2+
, zlib = require('zlib')
3+
, async = require('async')
4+
, path = require('path')
5+
, fs = require('fs')
6+
, ncp = require('ncp')
7+
, rimraf = require('rimraf')
8+
, tar = require('tar')
9+
, _url = require('url')
10+
, https = require('follow-redirects').https
11+
, proxyAgent = require('https-proxy-agent')
12+
, project = GLOBAL.lib.project
13+
, utils = GLOBAL.lib.utils;
1314

1415
/**
1516
* Downloads the package, unzips and untars into dir
@@ -85,7 +86,12 @@ var get = exports.get = function(pkg, url, dir) {
8586
secureProtocol: require('constants').SSL_OP_NO_TLSv1_2
8687
};
8788

88-
options.agent = new https.Agent(options);
89+
var proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || null;
90+
if (proxy !== null) {
91+
options.agent = new proxyAgent(proxy);
92+
} else {
93+
options.agent = new https.Agent(options);
94+
}
8995

9096
return download(options, dir);
9197
};

package.json

Lines changed: 2 additions & 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.8",
4+
"version" : "1.2.9",
55
"license" : "MIT",
66
"author": {
77
"name" : "CleverStack",
@@ -39,6 +39,7 @@
3939
"event-stream" : "~3.3.0",
4040
"findit" : "~2.0.0",
4141
"follow-redirects" : "~0.0.3",
42+
"https-proxy-agent" : "^1.0.0",
4243
"i" : "^0.3.2",
4344
"lodash" : "~3.4.0",
4445
"mkdirp" : "~0.5.0",

0 commit comments

Comments
 (0)