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

feat(node-fs): add support for multiple dirs #203

Merged
merged 8 commits into from Jan 12, 2024

Conversation

Aareksio
Copy link
Contributor

@Aareksio Aareksio commented Jan 5, 2024

πŸ”— Linked issue

nuxt/image#1177

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

As discussed, add support for serving files from multiple directories. At the moment of posting this PR the code scans dirs in order and returns first found file, meaning earlier dirs take precedence.

There are no docs in this repository mentioning programatic use of dir and the change is backwards compatible.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this ❀️

test/assets-2/bliss.jpg Outdated Show resolved Hide resolved
src/storage/node-fs.ts Outdated Show resolved Hide resolved
src/storage/node-fs.ts Outdated Show resolved Hide resolved
src/storage/node-fs.ts Outdated Show resolved Hide resolved
@Aareksio
Copy link
Contributor Author

Aareksio commented Jan 6, 2024

Reading the source, I think it may be better to skip throwing error when file is not found to let the IPX logic handle it with common error code: 1, 2. We currently throw slightly different error message. I find it unnecessary.

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (be4b092) 53.61% compared to head (daf8729) 56.02%.

Files Patch % Lines
src/storage/node-fs.ts 84.21% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #203      +/-   ##
==========================================
+ Coverage   53.61%   56.02%   +2.40%     
==========================================
  Files          14       14              
  Lines        1188     1203      +15     
  Branches       66       83      +17     
==========================================
+ Hits          637      674      +37     
+ Misses        548      526      -22     
  Partials        3        3              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@pi0
Copy link
Member

pi0 commented Jan 12, 2024

Re error, i mainly used new codes for each driver to make debugging easier against user setups.

@pi0
Copy link
Member

pi0 commented Jan 12, 2024

Thanks again! I have pushed few refactors to make it mergable hope you are happy with them and any PR more than welcome to improve ❀️

@pi0 pi0 merged commit 912203e into unjs:main Jan 12, 2024
4 checks passed
@Aareksio
Copy link
Contributor Author

Aareksio commented Jan 12, 2024

Thank you! I love how you used scoped fs by returning read function. Perhaps I shouldn't have overthinked the forbidden path, you are right this implies invalid configuration :)

I'll push updates to nuxt/image#1177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants