mirror of
https://gitcode.com/gh_mirrors/se/setup-uv.git
synced 2026-07-02 18:17:52 +00:00
60cc2b4585
Adds capability to maintain custom uv builds or to override the default sources
22 lines
546 B
TypeScript
22 lines
546 B
TypeScript
import { fetch as undiciFetch, ProxyAgent, type RequestInit } from "undici";
|
|
|
|
export function getProxyAgent() {
|
|
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
|
|
if (httpProxy) {
|
|
return new ProxyAgent(httpProxy);
|
|
}
|
|
|
|
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
|
|
if (httpsProxy) {
|
|
return new ProxyAgent(httpsProxy);
|
|
}
|
|
|
|
return undefined;
|
|
}
|
|
|
|
export const fetch = async (url: string, opts: RequestInit) =>
|
|
await undiciFetch(url, {
|
|
dispatcher: getProxyAgent(),
|
|
...opts,
|
|
});
|