-
-
Notifications
You must be signed in to change notification settings - Fork 845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return inserted, in addition to parsed #182
Conversation
What are the advantages of |
Less noise. and also arguably less confusion for the developer. Dotenv is not operating on any of those preset envs (except in the case it's also defined in the |
Sorry, I wasn't trying to suggest returning -var value = process.env[configKey] || config.parsed[configKey]
+var value = config.inserted[configKey] Feels like you're just trading where you ultimately have to do this check (from there to here) if you want to know what was already defined in Ultimately if you as a developer want some values from a file guaranteed to be present, why not just require a JSON file and assign it to your own custom global leaving global.my_example = require('./git-ignored-config.json')
db.connect(global.my_example.db_host) If you're shipping your code somewhere where you don't control the environment, it's your responsibility as a developer to choose unique (most likely namespaced) environment variables (e.g. not I agree that |
Let me make sure I follow, are you suggesting modules that add functionality on top of dotenv (like dotenv-expand) should just iterate through all the keys in |
If you want to know what dotenv parsed, check |
👍 I do think this good information to expose for plugins.
|
I agree with @jcblw. And it is very little overhead. I'll get this merged and released this week. |
@jcblw and @maxbeatty I'd like to get your guys' thoughts on this scenario:
SOME_ENV
, is preset on the machineSOME_ENV
is also set in the .env fileSOME_ENV
, correctly.In this scenario the value returned is not representative of what is set in memory.
This PR is proposing to additionally return an
inserted
object, but what do you guys think is the right move here.I came across this when patching up dotenv-expand. Any others building libs on top of dotenv would come across the same current bug and have to write their own patch. motdotla/dotenv-expand#6