mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-25 00:57:38 -04:00
fix(config/reader): only sync registries.default to registry when workspace contributes it (#11754)
The sync introduced in #11744 unconditionally overwrote the unnormalized registry value parsed from .npmrc with the normalized registries.default, causing a trailing slash to appear in config.registry when the user only configured a registry in .npmrc. Restrict the sync to cases where pnpm-workspace.yaml actually contributes a default registry different from what .npmrc provided.
This commit is contained in:
6
.changeset/config-reader-registry-sync-npmrc.md
Normal file
6
.changeset/config-reader-registry-sync-npmrc.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/config.reader": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Fix `config.registry` getting a trailing slash appended when `registry` is set in `.npmrc` and no `registries.default` is provided by `pnpm-workspace.yaml`. The sync from `registries.default` to `config.registry` introduced in #11744 now only fires when the workspace manifest actually contributes a different default.
|
||||
@@ -463,9 +463,10 @@ export async function getConfig (opts: {
|
||||
|
||||
// Sync registries.default to the top-level registry property so that
|
||||
// commands like login/logout that use opts.registry pick up the default
|
||||
// registry configured in pnpm-workspace.yaml.
|
||||
// Only sync when registry was not explicitly set via CLI.
|
||||
if (!explicitlySetKeys.has('registry')) {
|
||||
// registry configured in pnpm-workspace.yaml. Only sync when the workspace
|
||||
// manifest actually contributed a different default than what .npmrc provided,
|
||||
// and when registry was not explicitly set via CLI.
|
||||
if (!explicitlySetKeys.has('registry') && pnpmConfig.registries.default !== registriesFromNpmrc.default) {
|
||||
pnpmConfig.registry = pnpmConfig.registries.default
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user