@@ -11,7 +11,7 @@ import {CICDVariable} from "./variables-from-files.js";
11
11
import { GitData , GitSchema } from "./git-data.js" ;
12
12
import globby from "globby" ;
13
13
import micromatch from "micromatch" ;
14
- import axios from "axios" ;
14
+ import axios , { AxiosRequestConfig } from "axios" ;
15
15
import path from "path" ;
16
16
import { Argv } from "./argv.js" ;
17
17
@@ -418,7 +418,11 @@ export class Utils {
418
418
case "http" :
419
419
case "https" : {
420
420
try {
421
- const { status} = await axios . get ( `${ protocol } ://${ domain } :${ port } /${ projectPath } /-/raw/${ ref } /${ file } ` ) ;
421
+ const axiosConfig : AxiosRequestConfig = Utils . getAxiosProxyConfig ( ) ;
422
+ const { status} = await axios . get (
423
+ `${ protocol } ://${ domain } :${ port } /${ projectPath } /-/raw/${ ref } /${ file } ` ,
424
+ axiosConfig ,
425
+ ) ;
422
426
return ( status === 200 ) ;
423
427
} catch {
424
428
return false ;
@@ -442,4 +446,19 @@ export class Utils {
442
446
}
443
447
return lsFilesRes . stdout . split ( "\n" ) ;
444
448
}
449
+
450
+ static getAxiosProxyConfig ( ) : AxiosRequestConfig {
451
+ const proxyEnv = process . env . HTTPS_PROXY || process . env . HTTP_PROXY ;
452
+ if ( proxyEnv ) {
453
+ const proxyUrl = new URL ( proxyEnv ) ;
454
+ return {
455
+ proxy : {
456
+ host : proxyUrl . hostname ,
457
+ port : proxyUrl . port ? parseInt ( proxyUrl . port , 10 ) : 8080 ,
458
+ protocol : proxyUrl . protocol . replace ( ":" , "" ) ,
459
+ } ,
460
+ } ;
461
+ }
462
+ return { } ;
463
+ }
445
464
}
0 commit comments