fix: preserve env values when preload override is false#1019
Open
Gares95 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This updates preload override handling so explicit string false values are treated the same as the documented boolean false case.
It also adds focused coverage for environment and CLI preload options.
What changed
lib/main.jsnow uses the existing boolean parser when deciding whetherpopulateshould overwrite existing values.tests/test-config-cli.jsnow covers:DOTENV_CONFIG_OVERRIDE=falsepreserving an existing value.dotenv_config_override=falsepreserving an existing value.DOTENV_CONFIG_OVERRIDE=truecontinuing to overwrite an existing value.Why
Preload options arrive as strings from environment variables and CLI arguments. The existing parser already treats strings such as
false,0,no,off, and an empty string as false for other boolean options.Applying that same parser to
overridemakes preload behavior line up with the documented default while keeping stringtruebehavior unchanged.Tests run
npm ci --ignore-scripts:tests/test-config-cli.jsnpm ci --ignore-scripts:tests/test-config-cli.js,tests/test-config.js,tests/test-populate.js,tests/test-env-options.js,tests/test-cli-options.jsRisk/compatibility notes
overrideoptions.truestill enables override.trueand booleanfalsebehavior remains consistent with the documented option.overridestring enabling override would seefalse,0,no,off, and empty-string values treated as false.Maintainer notes
populateso env and CLI option parsing behavior remains unchanged.populatetest would be preferred.