lib: fix readdir in recursive mode with a buffer argument
Fixes: https://github.com/nodejs/node/issues/58892
Calling readdir with a Buffer argument and the recursive flag produces an ERR_INVALID_ARG_TYPE error. The expected behavior would be for the readdir functions not to error and return either an array of Buffers or Dirents (depending on options.withFileTypes)
Codecov Report
:x: Patch coverage is 96.61017% with 2 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 88.54%. Comparing base (4f24aff) to head (909880c).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| lib/internal/fs/promises.js | 93.10% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #60936 +/- ##
==========================================
+ Coverage 88.53% 88.54% +0.01%
==========================================
Files 703 703
Lines 208546 208596 +50
Branches 40217 40238 +21
==========================================
+ Hits 184634 184701 +67
+ Misses 15926 15905 -21
- Partials 7986 7990 +4
| Files with missing lines | Coverage Δ | |
|---|---|---|
| lib/fs.js | 98.20% <100.00%> (+0.01%) |
:arrow_up: |
| lib/internal/fs/promises.js | 98.03% <93.10%> (-0.12%) |
:arrow_down: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
correct handling of buffer arguments in recursive readdir aligns the behavior with people's expectations and makes the fs API more consistent
the Codecov report shows two uncovered lines in promises.js - adding a test for the recursive + Buffer path would close that gap and make the fix fully covered