230227.1 · chore(deps): remove `proxy-agent` and `form-data` in favor of `undici` (#672)
import { globalAgent } from 'node:https';
import { spawnSync } from 'child_process';
import { ProxyAgent } from 'undici';
import { getMergedConfig } from './config.js';
export default function proxy() {
let proxyUrl = getMergedConfig().proxy;
if (proxyUrl == null || proxyUrl === '') {
proxyUrl = spawnSync(
'git',
['config', '--get', '--path', 'https.proxy']
).stdout.toString();
}
if (proxyUrl == null || proxyUrl === '') {
return globalAgent;
} else {
return new ProxyAgent(proxyUrl);
}
}