Skip to content

Commit 635b244

Browse files
committed
feat: COREPACK_NPM_REGISTRY defaults to the regitry of npm
1 parent 7f7336b commit 635b244

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ same major line. Should you need to upgrade to a new major, use an explicit
302302
(useful for commands like `yarn init`).
303303

304304
- `COREPACK_NPM_REGISTRY` sets the registry base url used when retrieving
305-
package managers from npm. Default value is `https://registry.npmjs.org`
305+
package managers from npm. Default value is the result of command
306+
`npm config get registry`, which is typically `https://registry.npmjs.org/`
307+
unless it has been customized.
306308

307309
- `COREPACK_NPM_TOKEN` sets a Bearer token authorization header when connecting
308310
to a npm type registry.

mkshims.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ async function main() {
2121
const corepackPath = path.join(distDir, `corepack.js`);
2222
fs.writeFileSync(corepackPath, [
2323
`#!/usr/bin/env node`,
24+
`process.env.COREPACK_NPM_REGISTRY??=require('child_process').execSync('npm config get registry', {encoding: 'utf8'}).trim();`,
2425
`process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT??='0';`,
2526
`require('module').enableCompileCache?.();`,
2627
`require('./lib/corepack.cjs').runMain(process.argv.slice(2));`,
@@ -34,6 +35,7 @@ async function main() {
3435
const entryPath = path.join(distDir, `${binaryName}.js`);
3536
const entryScript = [
3637
`#!/usr/bin/env node`,
38+
`process.env.COREPACK_NPM_REGISTRY??=require('child_process').execSync('npm config get registry', {encoding: 'utf8'}).trim();`,
3739
`process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT??='1'`,
3840
`require('module').enableCompileCache?.();`,
3941
`require('./lib/corepack.cjs').runMain(['${binaryName}', ...process.argv.slice(2)]);`,

0 commit comments

Comments
 (0)