mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge pull request #12149 from heschong/meteor-fix-11718
Add https proxy support to meteor-installer
This commit is contained in:
@@ -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.
|
||||
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user