fix(fs/walk): do not apply exts filter to directory entries#7186
Open
LeSingh1 wants to merge 4 commits into
Open
fix(fs/walk): do not apply exts filter to directory entries#7186LeSingh1 wants to merge 4 commits into
LeSingh1 wants to merge 4 commits into
Conversation
When includeDirs is true and the exts option is set, directories were incorrectly being filtered out because they have no file extension. Directory entries should only be subject to the match and skip filters, not the exts filter. Fixes denoland#6736
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7186 +/- ##
=======================================
Coverage 94.57% 94.58%
=======================================
Files 636 637 +1
Lines 52142 52150 +8
Branches 9401 9401
=======================================
+ Hits 49315 49324 +9
- Misses 2249 2250 +1
+ Partials 578 576 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6736
When
includeDirsistrue(the default) and theextsoption is set, directory entries were incorrectly being filtered out by theextscheck because directories have no file extension. This meant that usingwalk(path, { exts: ['.ts'] })would not yield any directory entries at all, even thoughincludeDirsdefaults totrue.Before:
After:
Changes
fs/walk.ts: When yielding a directory entry (for the root path in bothwalkandwalkSync), passundefinedforextsto theinclude()helper so that directory paths are not subject to the file-extension filter. Thematchandskipregexp filters still apply to directories.fs/walk_test.ts: Updated the existingextstests to include the root directory"."in expected results. Added two new tests (walk()andwalkSync()) verifying that subdirectories are included when theextsoption is set.fs/testdata/walk/ext_with_subdir/: New testdata directory withx.tsandsubdir/y.rsto exercise the subdirectory case.Test plan
extstests now include the root dir"."in expected resultswalk() includes subdirs when using exts optionandwalkSync() includes subdirs when using exts optionpass