diff --git a/npm-packages/meteor-installer/README.md b/npm-packages/meteor-installer/README.md index 4d164e7194..b240fe71b2 100644 --- a/npm-packages/meteor-installer/README.md +++ b/npm-packages/meteor-installer/README.md @@ -57,3 +57,8 @@ npm install -g meteor --ignore-meteor-setup-exec-path ``` (or by setting the environment variable `npm_config_ignore_meteor_setup_exec_path=true`) + +### Proxy configuration + +Setting the `https_proxy` or `HTTPS_PROXY` environment variable to a valid proxy URL will cause the +downloader to use the configured proxy to retrieve the Meteor files. \ No newline at end of file diff --git a/npm-packages/meteor-installer/install.js b/npm-packages/meteor-installer/install.js index c495d31999..6f52bfb93b 100644 --- a/npm-packages/meteor-installer/install.js +++ b/npm-packages/meteor-installer/install.js @@ -1,4 +1,5 @@ const { DownloaderHelper } = require('node-downloader-helper'); +const HttpsProxyAgent = require('https-proxy-agent'); const cliProgress = require('cli-progress'); const Seven = require('node-7z'); const path = require('path'); @@ -143,6 +144,15 @@ try { download(); +function generateProxyAgent() { + const proxyUrl = process.env.https_proxy || process.env.HTTPS_PROXY; + if (!proxyUrl) { + return undefined; + } + + return new HttpsProxyAgent(proxyUrl); +} + function download() { const start = Date.now(); const downloadProgress = new cliProgress.SingleBar( @@ -158,6 +168,9 @@ function download() { retry: { maxRetries: 5, delay: 5000 }, override: true, fileName: tarGzName, + httpsRequestOptions: { + agent: generateProxyAgent() + } }); dl.on('progress', ({ progress }) => {