Skip to content

Commit

Permalink
Merge pull request serverless#5481 from serverless/sls-5480
Browse files Browse the repository at this point in the history
Create an HttpsProxyAgent for plugin list if necessary
  • Loading branch information
dschep authored Nov 14, 2018
2 parents 4cf2db5 + f5c225f commit 8c04460
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/plugins/plugin/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const fetch = require('node-fetch');
const BbPromise = require('bluebird');
const HttpsProxyAgent = require('https-proxy-agent');
const url = require('url');
const path = require('path');
const chalk = require('chalk');
const _ = require('lodash');
Expand Down Expand Up @@ -49,7 +51,20 @@ module.exports = {

getPlugins() {
const endpoint = 'https://raw.githubusercontent.com/serverless/plugins/master/plugins.json';
return fetch(endpoint).then((result) => result.json()).then((json) => json);

// Use HTTPS Proxy (Optional)
const proxy = process.env.proxy
|| process.env.HTTP_PROXY
|| process.env.http_proxy
|| process.env.HTTPS_PROXY
|| process.env.https_proxy;

const options = {};
if (proxy) {
options.agent = new HttpsProxyAgent(url.parse(proxy));
}

return fetch(endpoint, options).then((result) => result.json()).then((json) => json);
},

display(plugins) {
Expand Down

0 comments on commit 8c04460

Please sign in to comment.