-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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.06% 88.24% +0.17%
==========================================
Files 652 652
Lines 183544 183902 +358
Branches 35861 35864 +3
==========================================
+ Hits 161644 162282 +638
+ Misses 15151 14912 -239
+ Partials 6749 6708 -41
|
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. |
It's one thing that e.g.
|
929a225
to
86bde62
Compare
I fixed the issue by iterating over the arguments. It's kind of a mix between what was done previously. |
@@ -277,12 +229,9 @@ Dotenv::ParseResult Dotenv::ParsePath(const std::string_view path) { | |||
return ParseResult::Valid; | |||
} | |||
|
|||
void Dotenv::AssignNodeOptionsIfAvailable(std::string* node_options) const { |
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.
This removed implementation doesn't make any unnecessary copy, but your new implementation does.
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.
It's not unneccessery. It needs to be an std::string
for ProcessGlobalArgsInternal
86bde62
to
6d30720
Compare
I'm not a expert CPP developer, so LMK if I made a mistake. |
6d30720
to
3decd15
Compare
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 will error, but the env file is still parsed