-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
src: parse dotenv with the rest of the options #54913
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
4fcaea6
to
5f7688e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #54913 +/- ##
==========================================
+ Coverage 88.39% 88.40% +0.01%
==========================================
Files 652 654 +2
Lines 186777 187649 +872
Branches 36039 36093 +54
==========================================
+ Hits 165109 165899 +790
- Misses 14917 14994 +77
- Partials 6751 6756 +5
|
If it fixes a lot of things, shouldn't it add a lot of tests? |
a91e51c
to
14e9cd0
Compare
Tests have been added + rebased. |
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.
The way the test is done is not very robust: if the error message changes in the future, it will be wrong but still pass. It would be better to assert the actual error
14e9cd0
to
9121453
Compare
9121453
to
854a3c3
Compare
The failed GitHub tests are flakes, could someone start a CI? I don't have the permissions to start one without approvals |
I have to incorporate #53060 |
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.
Can you rebase your branch with main
, with the recent changes, it is extremely hard to review.
854a3c3
to
7ac00c8
Compare
I'm currently facing the problem of: The files aren't parsed in the same order they were supplied. It's loading all of the optionals, then all of the normals. Any ideas? |
950cb47
to
929a225
Compare
Well you are grabbing them all by creating vectors and referencing those via You're likely respecting argument order inside each vector, it's just you're segregating them by optionality first |
Exactly... I just don't know how to fix that. |
I'm not a expert CPP developer, so LMK if I made a mistake. |
6d30720
to
3decd15
Compare
As shocking as it may seem, all Github failures are unrelated flakes. @anonrig is this better to what you had in mind? |
First of all, thanks a lot for still working on a proper fix for the env file option issues, @RedYetiDev.
I saw that you already fixed it, but maybe it could be solved much easier: From my understanding, the order of My proposed solution is, first reading all the "required" env files in the order they appear in the option list, then all "optional" ones, and adding a note about the env file processing order to the documentation. |
IMHO the current setup makes more sense, that is, parse in the order the options where passed. |
3decd15
to
f0ab517
Compare
I've modified the implementation to use a new |
630ee2f
to
31b6f4e
Compare
@anonrig are you still blocking? I think I've resolved all your concerns. As for the string copying, I believe it's needed, as other functions are expecting a string. |
PTAL @nodejs/cpp-reviewers |
31b6f4e
to
d0b1368
Compare
Any other concerns, @lemire? |
@RedYetiDev I don't have any concern, but I'd like to hear what @anonrig has to say about this PR. He is still asking for changes which I consider blocking. One thing is certain: this has been opened in September. We should do something with it. |
Closes #54385Fixes #54255
Ref #54232
I don't think this breaks anything. IIUC, the Dotenv parser was setup before everything else so that it triggered before V8 initialized, however, even it's setup after the options are parsed, V8 still hasn't been initialized, so it should be fine.
This fixes all currently known dotenv edge cases, as it doesn't need a custom parser.
Such as:
node script.js --env-file .env node --env-file-ABCD .env node -- --env-file .env node --invalid --env-file .env # this would've errored, but the env file is still parsed