Skip to content

Commit 16210ca

Browse files
apapirovskiTrott
authored andcommitted
fs: fix promisified fs.readdir withFileTypes
PR-URL: #22832 Reviewed-By: Bryan English <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent de37ba3 commit 16210ca

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/internal/fs/promises.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ async function readdir(path, options) {
317317
path = toPathIfFileURL(path);
318318
validatePath(path);
319319
const result = await binding.readdir(pathModule.toNamespacedPath(path),
320-
options.encoding, !!options.withTypes,
320+
options.encoding,
321+
!!options.withFileTypes,
321322
kUsePromises);
322323
return options.withFileTypes ?
323324
getDirectoryEntriesPromise(path, result) :

test/parallel/test-fs-readdir-types.js

+8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ fs.readdir(readdirDir, {
5757
assertDirents(dirents);
5858
}));
5959

60+
// Check the promisified version
61+
assert.doesNotReject(async () => {
62+
const dirents = await fs.promises.readdir(readdirDir, {
63+
withFileTypes: true
64+
});
65+
assertDirents(dirents);
66+
});
67+
6068
// Check for correct types when the binding returns unknowns
6169
const UNKNOWN = constants.UV_DIRENT_UNKNOWN;
6270
const oldReaddir = binding.readdir;

0 commit comments

Comments
 (0)