Skip to content

fix: clear exclusive param siblings when setting from CLI#9023

Open
umeshmore45 wants to merge 3 commits intonpm:latestfrom
umeshmore45:fix/exclusive-params-env-clearing
Open

fix: clear exclusive param siblings when setting from CLI#9023
umeshmore45 wants to merge 3 commits intonpm:latestfrom
umeshmore45:fix/exclusive-params-env-clearing

Conversation

@umeshmore45
Copy link
Contributor

fix: clear exclusive sibling configs from env when one is set via CLI

What's the problem?

If you set an exclusive param via CLI (e.g. --save-prod) but a sibling
(npm_config_save_dev=true) is already in the environment, child processes
inherit both and crash with a conflict. This was also the root cause of the
--min-release-age + --before issue in #9005.

What changed

When setEnvs exports a non-default exclusive config, it now resets that
param's siblings to their defaults in the env — so child processes never
see a conflict. Works generically for all exclusive pairs, not just this one.

Tests

Added a test for the case where save-prod is set via CLI while save-dev
is already in env — verifies save-dev gets reset to its default.

References

Fixes #9005

When an exclusive config parameter is set via CLI, now clear its
sibling parameters in the environment to prevent child processes
from seeing conflicting values. Adds test coverage for the scenario
where save-prod is set via CLI while save-dev exists in env.
@umeshmore45 umeshmore45 requested a review from a team as a code owner February 24, 2026 13:44
Cleaned up the test environment configuration by removing unnecessary environment variables from the  file. This simplifies the test setup and improves clarity.
…deprecated siblings

Introduced new test cases to verify that exclusive parameters do not clear their siblings when  is set to false or when they are marked as deprecated. This ensures correct behavior in the configuration management for CLI and environment variables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] min-release-age config error if any dependencies use ~ version range

1 participant