deno-dotenv icon indicating copy to clipboard operation
deno-dotenv copied to clipboard

overwrite env files with envvar

Open jchannon opened this issue 2 years ago • 1 comments

If you have an .env file with a value set but then set an env var whilst running deno it is not overwritten.

in deployment cases often, envvars will be set as part of deployment for prod secrets that you may not want in files in source control

TwitterApiKey=233

TwitterApiKey=456 deno run --allow-read --allow-env mod.ts

console.log(dotenvConfig.TwitterApiKey) = 233 but I would expect it to be 456

jchannon avatar Jan 06 '22 09:01 jchannon

System env import works one way currently — that is, dotenv exports (if it was configured to) the config as environment variables, but ignores what already exists in the environment. Usually this is enough, because you can override your environment by just substituting a different .env file in a production setting.

However, you may be right, that it could be convenient to be able to override the .env settings by just explicitly setting an environment variable

If this is a desired feature, I could implement it easily. My worry is that my PRs are not getting reviewed by anyone. The current code really needs a good deal of refactor, which I would strongly recommend doing, before implementing other features. Yet, I can't get ahold of the author of this package

If I fail in that, I might as well develop my own fork of this repository…

pasha-bolokhov avatar Feb 03 '22 04:02 pasha-bolokhov