Skip to content

fs: honor encoding option in glob APIs#62068

Open
jorgitin02 wants to merge 1 commit intonodejs:mainfrom
jorgitin02:fix/59202-glob-buffer-encoding
Open

fs: honor encoding option in glob APIs#62068
jorgitin02 wants to merge 1 commit intonodejs:mainfrom
jorgitin02:fix/59202-glob-buffer-encoding

Conversation

@jorgitin02
Copy link

@jorgitin02 jorgitin02 commented Mar 2, 2026

Summary

  • honor encoding for fs.globSync(), fs.glob(), and fsPromises.glob() so encoding: 'buffer' returns Buffer paths and Buffer dirent names with withFileTypes
  • avoid mutating cached dirents by cloning at output conversion boundaries
  • add regression coverage for buffer parity, invalid encoding, absolute-pattern behavior, and document the option/return types (including async iterator buffer output)

Testing

  • python3 tools/test.py test/parallel/test-fs-glob.mjs test/parallel/test-fs-glob-throw.mjs test/parallel/test-fs-readdir-buffer.js test/parallel/test-fs-readdir-types.js

#59202.

@jorgitin02
Copy link
Author

Compact update: this addresses the #59202 review blockers (no cached-dirent mutation, YAML metadata added, invalid-encoding + absolute-pattern tests).

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Mar 2, 2026
@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 96.42857% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.66%. Comparing base (4d0cb65) to head (8aaa9f4).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/fs/glob.js 96.42% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62068      +/-   ##
==========================================
- Coverage   91.63%   89.66%   -1.97%     
==========================================
  Files         337      676     +339     
  Lines      140376   206327   +65951     
  Branches    21768    39541   +17773     
==========================================
+ Hits       128627   184994   +56367     
- Misses      11527    13464    +1937     
- Partials      222     7869    +7647     
Files with missing lines Coverage Δ
lib/internal/fs/glob.js 92.24% <96.42%> (+5.57%) ⬆️

... and 458 files with indirect coverage changes

🚀 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.

Align glob, globSync, and fsPromises.glob with encoding semantics.

When encoding is 'buffer', return Buffer paths and Buffer dirent names.

Add regression tests and documentation updates to lock behavior.
@jorgitin02 jorgitin02 force-pushed the fix/59202-glob-buffer-encoding branch from 8aaa9f4 to 2622646 Compare March 2, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants