Skip to content

Commit 24a35f9

Browse files
apapirovskitargos
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 08e427a commit 24a35f9

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
@@ -299,7 +299,8 @@ async function readdir(path, options) {
299299
path = getPathFromURL(path);
300300
validatePath(path);
301301
const result = await binding.readdir(pathModule.toNamespacedPath(path),
302-
options.encoding, !!options.withTypes,
302+
options.encoding,
303+
!!options.withFileTypes,
303304
kUsePromises);
304305
return options.withFileTypes ?
305306
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)