11import { createWriteStream } from "fs" ;
22import * as fs from "fs/promises" ;
33import fetch from "node-fetch" ;
4+ import { HttpsProxyAgent } from "https-proxy-agent" ;
45import { pipeline } from "stream/promises" ;
5- import tar from "tar" ;
6+ import * as tar from "tar" ;
67import { execSync } from "child_process" ;
78
89import { ARCH_MAPPING , CONFIG , PLATFORM_MAPPING } from "./config.js" ;
910
11+ // Get proxy URL from environment variables (standard convention)
12+ function getProxyUrl ( ) {
13+ return process . env . HTTPS_PROXY ||
14+ process . env . https_proxy ||
15+ process . env . HTTP_PROXY ||
16+ process . env . http_proxy ||
17+ null ;
18+ }
19+
1020async function install ( ) {
1121 if ( process . platform === "android" ) {
1222 console . log ( "Installing, may take a moment..." ) ;
@@ -32,9 +42,16 @@ async function install() {
3242 url = url . replace ( / { { version} } / g, version ) ;
3343 url = url . replace ( / { { bin_ n a m e } } / g, binName ) ;
3444
45+ // Configure fetch options with proxy support
46+ const fetchOptions = { } ;
47+ const proxyUrl = getProxyUrl ( ) ;
48+ if ( proxyUrl ) {
49+ console . log ( 'Using proxy:' , proxyUrl ) ;
50+ fetchOptions . agent = new HttpsProxyAgent ( proxyUrl ) ;
51+ }
3552
3653 console . log ( 'fetching from URL' , url )
37- const response = await fetch ( url ) ;
54+ const response = await fetch ( url , fetchOptions ) ;
3855 if ( ! response . ok ) {
3956 throw new Error ( "Failed fetching the binary: " + response . statusText ) ;
4057 }
0 commit comments