Skip to content

feat(dotenv): add URL as envPath type #6621

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

Merged
merged 2 commits into from
Apr 30, 2025
Merged

feat(dotenv): add URL as envPath type #6621

merged 2 commits into from
Apr 30, 2025

Conversation

eikooc
Copy link
Contributor

@eikooc eikooc commented Apr 23, 2025

This PR fixes #6620, by adding URL as a valid type to the envPath parameter in the LoadOptions interface.

@eikooc eikooc requested a review from kt3k as a code owner April 23, 2025 10:46
@CLAassistant
Copy link

CLAassistant commented Apr 23, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.53%. Comparing base (b55ce82) to head (297ca70).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6621      +/-   ##
==========================================
- Coverage   94.54%   94.53%   -0.01%     
==========================================
  Files         580      580              
  Lines       43887    43887              
  Branches     6501     6501              
==========================================
- Hits        41492    41490       -2     
- Misses       2352     2354       +2     
  Partials       43       43              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -29,6 +29,18 @@ Deno.test("load() handles non-existent .env files", async () => {
assertEquals({}, loadSync(loadOptions));
});

Deno.test("load() handles URL as path for .env files", async () => {
const conf = loadSync({
envPath: new URL(path.join(testdataDir, ".env"), import.meta.url),
Copy link
Member

Choose a reason for hiding this comment

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

new URL(path.join(testdataDir, ".env"), import.meta.url)

This doesn't work on windows as the paths are \ separated on windows, but that doesn't work as URL string

You need to call toFileUrl from @std/path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean like this:

new URL(
  toFileUrl(path.join(testdataDir, ".env")),
  import.meta.url,
)

?

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@eikooc eikooc requested a review from kt3k April 25, 2025 07:56
@kt3k kt3k changed the title fix(dotenv): Add URL as valid envPath type feat(dotenv): add URL as envPath type Apr 25, 2025
@eikooc
Copy link
Contributor Author

eikooc commented Apr 29, 2025

Anything missing @kt3k for this to be merged?

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in reviewing. This now looks good to me. Thank you for your contribution!

@kt3k kt3k merged commit 73a0065 into denoland:main Apr 30, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong type for parameter envPath in @std/dotenv load
3 participants