src: add --env-file-if-exists flag#53060
Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom Sep 16, 2024
BoscoDomingo:feature/optional-env-file-argument
Merged
src: add --env-file-if-exists flag#53060nodejs-github-bot merged 1 commit intonodejs:mainfrom BoscoDomingo:feature/optional-env-file-argument
--env-file-if-exists flag#53060nodejs-github-bot merged 1 commit intonodejs:mainfrom
BoscoDomingo:feature/optional-env-file-argument
Conversation
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.
Add a new flag,
--env-file-if-existsthat allows loading .env files without throwing an error if they don't exist.Achieved by returning an
env_file_datastruct instead of just the paths of the .env files. This tells the loader if the file itself is required or not, thus allowing to not throw an error if the file doesn't exist and is optional, without breaking existing behaviours with--env-file(we could maybe show a warning if an optional file is missing?).Usage:
If
B.envexists, it will load its environment variables and overwrite those that conflict withA.env. If it doesn't, node will continue as normal.Fixes: #50993
Refs: #51451