Skip to content

feat: support reading proxy from env #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"buffer-builder": "^0.2.0",
"extract-zip": "^2.0.1",
"google-protobuf": "^3.11.4",
"https-proxy-agent": "^5.0.1",
"immutable": "^4.0.0",
"node-fetch": "^2.6.0",
"rxjs": "^7.4.0",
Expand Down
4 changes: 4 additions & 0 deletions tool/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import extractZip = require('extract-zip');
import {promises as fs, existsSync, mkdirSync} from 'fs';
import fetch from 'node-fetch';
import {HttpsProxyAgent} from 'https-proxy-agent';
import * as p from 'path';
import * as shell from 'shelljs';
import {extract as extractTar} from 'tar';
Expand Down Expand Up @@ -188,8 +189,11 @@ async function downloadRelease(options: {
outPath: string;
}): Promise<void> {
console.log(`Downloading ${options.repo} release asset.`);
const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || process.env.https_proxy || process.env.http_proxy;
const agent = proxy ? new HttpsProxyAgent(proxy) : undefined;
const response = await fetch(options.assetUrl, {
redirect: 'follow',
agent,
});
if (!response.ok) {
throw Error(
Expand Down