Skip to content
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: use for loop in Dotenv::GetPathFromArgs #54385

Closed
wants to merge 2 commits into from

Conversation

RedYetiDev
Copy link
Member

@RedYetiDev RedYetiDev commented Aug 14, 2024

This PR replaces the old while loop with a newer for loop.

Fixes the following edge cases:

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 processed

Unfortunately, this introduces an edge case where some argument parameters, such as --eval <...> cause any future --env-file arguments to be ignored.

node --eval "1+1" --env-file notparsed.env

Fixes #54255
Fixes #54232
Related to #54237

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Aug 14, 2024
@RedYetiDev RedYetiDev added the dotenv Issues and PRs related to .env file parsing label Aug 14, 2024
@RedYetiDev RedYetiDev added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Aug 14, 2024
Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a cc test for testing only this function and every edge case you're targeting?

src/node_dotenv.cc Outdated Show resolved Hide resolved
@RedYetiDev RedYetiDev force-pushed the patch-93 branch 2 times, most recently from ed754f2 to b7af227 Compare August 15, 2024 01:45
@RedYetiDev
Copy link
Member Author

RedYetiDev commented Aug 15, 2024

@anonrig would you mind restarting the Github CI now that #54391 landed?

Actually I'm going to rebase for it.

src/node_dotenv.cc Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.07%. Comparing base (2c14615) to head (35c4dae).
Report is 268 commits behind head on main.

Files with missing lines Patch % Lines
src/node_dotenv.cc 80.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54385      +/-   ##
==========================================
- Coverage   87.08%   87.07%   -0.01%     
==========================================
  Files         648      648              
  Lines      182341   182338       -3     
  Branches    34982    34981       -1     
==========================================
- Hits       158783   158773      -10     
- Misses      16831    16833       +2     
- Partials     6727     6732       +5     
Files with missing lines Coverage Δ
src/node_dotenv.cc 81.36% <80.00%> (-0.35%) ⬇️

... and 24 files with indirect coverage changes

@RedYetiDev
Copy link
Member Author

@anonrig Do you think this should land (eventually), or it should be held-off, and a redone GetPathFromArgs would be better, one that doesn't have these edge cases?

@RedYetiDev
Copy link
Member Author

Closing in favor of #54913

@RedYetiDev RedYetiDev closed this Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. dotenv Issues and PRs related to .env file parsing needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotenv::GetPathFromArgs matches --env-file* Script argument --env-file is wrongly used as node option
3 participants