-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Adds dotenv to load configurations #5013
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. I don't use dotenv, but I think I should re-look.
https://www.npmjs.com/package/dotenv#preload
Do you think you should just bake this into the npm scripts (npx?).
"This is the preferred approach when using import instead of require."
Also, you're trying and catch, but this is the idiom in the docs:
const result = dotenv.config()
if (result.error) {
throw result.error
}
console.log(result.parsed)
Based on that, it seems that it won't throw? In other words, if we don't want to report on the error, we can just ignore? Presumably, you put in the catch as a result of your using it and knowing its needed, so I'm just asking.
Codecov Report
@@ Coverage Diff @@
## master #5013 +/- ##
==========================================
- Coverage 94.26% 94.24% -0.03%
==========================================
Files 121 121
Lines 8760 8760
==========================================
- Hits 8258 8256 -2
- Misses 502 504 +2
Continue to review full report at Codecov.
|
I recently came across more configuration possibilities like nconf etc.. May be worth exploring. |
I've been using https://github.com/lorenwest/node-config for a few years. |
I need to jump back on this at one point! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Thanks for opening this pull request!
|
Adds dotenv that let us read contents of a
.env
file to load environment variables automatically. Will likely be used alongside #4960