Skip to content

Commit 8766fdf

Browse files
committed
Tweaks
1 parent b65c8df commit 8766fdf

6 files changed

+39
-14
lines changed

.pnp.cjs

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

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,14 @@ This command will retrieve the given package manager from the specified archive
104104

105105
## Environment Variables
106106

107+
- `COREPACK_ENABLE_NETWORK` can be set to `0` to prevent it from downloading code from remote locations. In that case, you're expected to have already setup your local package managers via the `corepack prepare` / `corepack hydrate` workflow.
108+
109+
- `COREPACK_HOME` is the location where the Corepack files will be stored. By default its value is `$HOME/.node/corepack`.
110+
107111
- `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`).
108112

113+
- `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are supported through [`global-agent`](https://github.com/gajus/global-agent).
114+
109115
## Contributing
110116

111117
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
@@ -26,6 +26,7 @@
2626
"@babel/plugin-transform-modules-commonjs": "^7.14.0",
2727
"@babel/preset-typescript": "^7.13.0",
2828
"@types/debug": "^4.1.5",
29+
"@types/global-agent": "^2.1.1",
2930
"@types/jest": "^26.0.23",
3031
"@types/node": "^13.9.2",
3132
"@types/semver": "^7.1.0",

sources/httpUtils.ts

+13-14
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@ import {UsageError} from 'clipanion';
22
import {RequestOptions} from 'https';
33
import {IncomingMessage} from 'http';
44

5+
let globalAgentBootstrapped = false;
6+
7+
async function setupGlobalAgent() {
8+
if (globalAgentBootstrapped)
9+
return;
10+
11+
const {bootstrap} = await import(`global-agent`);
12+
bootstrap({environmentVariableNamespace: ``});
13+
14+
globalAgentBootstrapped = true;
15+
}
16+
517
export async function fetchUrlStream(url: string, options: RequestOptions = {}) {
618
if (process.env.COREPACK_ENABLE_NETWORK === `0`)
719
throw new UsageError(`Network access disabled by the environment; can't reach ${url}`);
820

9-
await setupProxy();
21+
await setupGlobalAgent();
1022

1123
const {default: https} = await import(`https`);
1224

@@ -25,19 +37,6 @@ export async function fetchUrlStream(url: string, options: RequestOptions = {})
2537
});
2638
}
2739

28-
let globalAgentBootstrapped = false;
29-
30-
async function setupProxy() {
31-
if (globalAgentBootstrapped) {
32-
return;
33-
}
34-
const {bootstrap} = await import('global-agent');
35-
bootstrap({
36-
environmentVariableNamespace: ''
37-
});
38-
globalAgentBootstrapped = true;
39-
}
40-
4140
export async function fetchAsBuffer(url: string, options?: RequestOptions) {
4241
const response = await fetchUrlStream(url, options);
4342

yarn.lock

+8
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,13 @@ __metadata:
10651065
languageName: node
10661066
linkType: hard
10671067

1068+
"@types/global-agent@npm:^2.1.1":
1069+
version: 2.1.1
1070+
resolution: "@types/global-agent@npm:2.1.1"
1071+
checksum: 33fddd83781706b60996d42e6e60a8a96b4163f5b54f5052c97b448edf8e7c834e9395613cec37a39da8d1d5286382e85ec09ba6b908fab5638055f7d6f76397
1072+
languageName: node
1073+
linkType: hard
1074+
10681075
"@types/graceful-fs@npm:^4.1.2":
10691076
version: 4.1.5
10701077
resolution: "@types/graceful-fs@npm:4.1.5"
@@ -2371,6 +2378,7 @@ __metadata:
23712378
"@babel/plugin-transform-modules-commonjs": ^7.14.0
23722379
"@babel/preset-typescript": ^7.13.0
23732380
"@types/debug": ^4.1.5
2381+
"@types/global-agent": ^2.1.1
23742382
"@types/jest": ^26.0.23
23752383
"@types/node": ^13.9.2
23762384
"@types/semver": ^7.1.0

0 commit comments

Comments
 (0)