summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_fs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/_fs')
-rw-r--r--ext/node/polyfills/_fs/_fs_dirent.ts2
-rw-r--r--ext/node/polyfills/_fs/_fs_readdir.ts10
2 files changed, 8 insertions, 4 deletions
diff --git a/ext/node/polyfills/_fs/_fs_dirent.ts b/ext/node/polyfills/_fs/_fs_dirent.ts
index 0f80fc135..d4ad6bb43 100644
--- a/ext/node/polyfills/_fs/_fs_dirent.ts
+++ b/ext/node/polyfills/_fs/_fs_dirent.ts
@@ -2,7 +2,7 @@
import { notImplemented } from "ext:deno_node/_utils.ts";
export default class Dirent {
- constructor(private entry: Deno.DirEntry) {}
+ constructor(private entry: Deno.DirEntry & { parentPath: string }) {}
isBlockDevice(): boolean {
notImplemented("Deno does not yet support identification of block devices");
diff --git a/ext/node/polyfills/_fs/_fs_readdir.ts b/ext/node/polyfills/_fs/_fs_readdir.ts
index f8c0a59d6..3b314227d 100644
--- a/ext/node/polyfills/_fs/_fs_readdir.ts
+++ b/ext/node/polyfills/_fs/_fs_readdir.ts
@@ -11,7 +11,7 @@ import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs";
import { Buffer } from "node:buffer";
import { promisify } from "ext:deno_node/internal/util.mjs";
-function toDirent(val: Deno.DirEntry): Dirent {
+function toDirent(val: Deno.DirEntry & { parentPath: string }): Dirent {
return new Dirent(val);
}
@@ -67,13 +67,15 @@ export function readdir(
}
try {
- asyncIterableToCallback(Deno.readDir(path.toString()), (val, done) => {
+ path = path.toString();
+ asyncIterableToCallback(Deno.readDir(path), (val, done) => {
if (typeof path !== "string") return;
if (done) {
callback(null, result);
return;
}
if (options?.withFileTypes) {
+ val.parentPath = path;
result.push(toDirent(val));
} else result.push(decode(val.name));
}, (e) => {
@@ -130,8 +132,10 @@ export function readdirSync(
}
try {
- for (const file of Deno.readDirSync(path.toString())) {
+ path = path.toString();
+ for (const file of Deno.readDirSync(path)) {
if (options?.withFileTypes) {
+ file.parentPath = path;
result.push(toDirent(file));
} else result.push(decode(file.name));
}