Merge pull request #12149 from heschong/meteor-fix-11718

Add https proxy support to meteor-installer
This commit is contained in:
Gabriel Grubba
2022-10-24 10:29:21 -03:00
committed by GitHub
2 changed files with 18 additions and 0 deletions

View File

@@ -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.

View File

@@ -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 }) => {