Skip to content

src: don't overwrite environment from .env file

This commit adds a check to see if an environment variable that is found in the .env file is already set in the environment. If it is, then the value from the .env file is not used.

The docs from https://github.com/nodejs/node/pull/48890 say:

If the same variable is defined in the environment and in the file, the value from the environment takes precedence.

In my testing, I found that not to be the case, so I went to look for a solution.

Caveats. I am not a C++ programmer and have never tried to read, understand or contribute back to a C++ code base before. This is a naive solution. Please feel free to criticize and correct my C++.

I know the v20.6.0 release is very close, but as dotenv support is a notable feature, I think this should join the release so that we don't push a feature that contradicts its own documentation.

Merge request reports

Loading