| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Review requested:
|
Sorry, something went wrong.
There was a problem hiding this comment.
this is a breaking change, but I hope it's fine given that dotenv is experimental (and I don't imagine many developers relying on this behavior? 🤔)
I am also not sure about the rational, personally if a new env file is loaded onto process.env I would expect that it would override whatever else is there 🤔
Sorry, something went wrong.
There was a problem hiding this comment.
If this is a problem I can keep the existing behavior.
Since I am thinking of making more changes in this space, to avoid churn and I would prefer this PR not to be a semver-major one if possible.
Sorry, something went wrong.
There was a problem hiding this comment.
Given how trivial it is to load a .env file onto process.env I even wonder if we could deprecate/remove process.loadEnvFile.
To me personally it feels much clearer to have this sort of operation more manual and have the user load their .env files withloadEnvFile and then use the values to populate process.env themselves if and how they want (with any overriding, filtering, etc. logic).
Sorry, something went wrong.
Codecov Report❌ Patch coverage is 84.61538% with 8 lines in your changes missing coverage. Please review.
@@ Coverage Diff @@
## main #59125 +/- ##
==========================================
+ Coverage 90.03% 90.05% +0.02%
==========================================
Files 648 648
Lines 190967 190984 +17
Branches 37425 37443 +18
==========================================
+ Hits 171931 171988 +57
+ Misses 11665 11625 -40
Partials 7371 7371
... and 40 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
I don't get it, how is process.loadEnvFile not user facing? |
Sorry, something went wrong.
Sorry, yeah my wording there is misleading, yes, of course process.loadEnvFile is user facing, my idea here was to add another function (still user facing) that is a generalization of process.loadEnvFile. Basically process.loadEnvFile loads a dotenv file onto an object, and that object is (necessarily) process.env, so I was thinking, wouldn't it make more sense to have a loadEnvFile utility that allows the user to load a dotenv file onto any object? (and that object could even be process.env itself, making process.loadEnvFile not really necessary anymore). |
Sorry, something went wrong.
|
My idea here was related on having a counterpart for parseEnv, there being a utility for parsing a dotenv content but not one for loading that from a file feels to me like a missing API. I was also thinking of maybe trying to take this even a step further and have a node:dotenv module where these two functions plus any potential new dotenv function could live (like for serializing an object into a dotenv file, of functions for validating dotenv content, etc...), this could be a nice little new module that gives users a bunch of useful tooling for dealing with dotenv files 🙂 (I am thinking of also tooling authors that might want to use node for doing more complex dotenv operations) |
Sorry, something went wrong.
|
It seems redundant when you can basically do the same with util.parseEnv(fs.readFileSync('.env', 'utf8')). |
Sorry, something went wrong.
Mh... under that argument I'd also say that process.loadEnvFile is also redundant since you can do the same with: Object.assign(process.env, util.parseEnv(fs.readFileSync('.env', 'utf8')))no? 🤔 |
Sorry, something went wrong.
|
Wasn't util.parseEnv introduced because process.loadEnvFile was too narrow? |
Sorry, something went wrong.
I don't know to be honest... I just saw that they were introduced together (#51476) |
Sorry, something went wrong.
|
Closing since I don't think we're going to go with this API due to the conversation above ( 🥹 ) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
We already have this logic in place for process.loadEnvFile so I figured that it could make sense to just repurpose it also provide a user facing function.
This function is the analogous of util.parseEnv but for files.