Lazy import proxy-agent

This commit is contained in:
Fedor Indutny 2024-03-20 11:05:10 -07:00 committed by GitHub
parent 83e8f4b59d
commit 091b50c414
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 60 additions and 39 deletions

View file

@ -24,13 +24,15 @@ export function getCertificateAuthority(): string {
return config.get('certificateAuthority');
}
export function getGotOptions(): GotOptions {
export type { GotOptions };
export async function getGotOptions(): Promise<GotOptions> {
const certificateAuthority = getCertificateAuthority();
const proxyUrl = getProxyUrl();
const agent = proxyUrl
? {
http: createProxyAgent(proxyUrl),
https: createProxyAgent(proxyUrl),
http: await createProxyAgent(proxyUrl),
https: await createProxyAgent(proxyUrl),
}
: {
http: new HTTPAgent(),