File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
packages/cubejs-backend-shared/src Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ import { exec } from 'child_process';
22import { ProxyAgent } from 'proxy-agent' ;
33import { HttpsProxyAgent } from 'https-proxy-agent' ;
44
5+ let npmProxy : string ;
6+ let npmProxyInitialized = false ;
7+
58function getCommandOutput ( command : string ) {
69 return new Promise < string > ( ( resolve , reject ) => {
710 exec ( command , ( error , stdout ) => {
@@ -19,22 +22,26 @@ function getCommandOutput(command: string) {
1922 * @deprecated
2023 * use ProxyAgent instead
2124 */
22- export async function getProxySettings ( ) {
25+ export async function getProxySettings ( ) : Promise < string > {
2326 const [ proxy ] = (
2427 await Promise . all ( [ getCommandOutput ( 'npm config -g get https-proxy' ) , getCommandOutput ( 'npm config -g get proxy' ) ] )
2528 )
2629 . map ( ( s ) => s . trim ( ) )
2730 . filter ( ( s ) => ! [ 'null' , 'undefined' , '' ] . includes ( s ) ) ;
2831
32+ npmProxyInitialized = true ;
33+
2934 return proxy ;
3035}
3136
3237export async function getHttpAgentForProxySettings ( ) {
33- const proxy = await getProxySettings ( ) ;
38+ if ( ! npmProxyInitialized ) {
39+ npmProxy = await getProxySettings ( ) ;
40+ }
3441
35- if ( proxy ) {
42+ if ( npmProxy ) {
3643 console . warn ( 'Npm proxy settings are deprecated. Please use HTTP_PROXY, HTTPS_PROXY environment variables instead.' ) ;
37- return new HttpsProxyAgent ( proxy ) ;
44+ return new HttpsProxyAgent ( npmProxy ) ;
3845 }
3946
4047 return new ProxyAgent ( ) ;
You can’t perform that action at this time.
0 commit comments