Skip to content

Commit 876ce02

Browse files
Djalerarcanis
andauthoredApr 7, 2022
feat: auto setup proxy for http requests (#69)
* feat: auto setup proxy for http requests * Adds dependencies * Triggers CI again Co-authored-by: Maël Nison <[email protected]>
1 parent 9d4bb08 commit 876ce02

File tree

38 files changed

+679
-8
lines changed

38 files changed

+679
-8
lines changed
 

‎.pnp.cjs

+347
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

‎README.md

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ This command will retrieve the given package manager from the specified archive
110110

111111
- `COREPACK_ROOT` has no functional impact on Corepack itself; it's automatically being set in your environment by Corepack when it shells out to the underlying package managers, so that they can feature-detect its presence (useful for commands like `yarn init`).
112112

113+
- `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are supported through [`node-proxy-agent`](https://github.com/TooTallNate/node-proxy-agent).
114+
113115
## Contributing
114116

115117
If you want to build corepack yourself, you can build the project like this:

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"eslint-plugin-arca": "^0.9.5",
4545
"jest": "^26.0.0",
4646
"nock": "^13.0.4",
47+
"proxy-agent": "^4.0.1",
4748
"rimraf": "^3.0.2",
4849
"semver": "^7.1.3",
4950
"supports-color": "^7.1.0",

‎sources/httpUtils.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ export async function fetchUrlStream(url: string, options: RequestOptions = {})
88

99
const {default: https} = await import(`https`);
1010

11+
const {default: ProxyAgent} = await import(`proxy-agent`);
12+
13+
const proxyAgent = new ProxyAgent();
14+
1115
return new Promise<IncomingMessage>((resolve, reject) => {
12-
const request = https.get(url, options, response => {
16+
const request = https.get(url, {...options, agent: proxyAgent}, response => {
1317
const statusCode = response.statusCode ?? 500;
1418
if (!(statusCode >= 200 && statusCode < 300))
1519
return reject(new Error(`Server answered with HTTP ${statusCode}`));

0 commit comments

Comments
 (0)
Please sign in to comment.