diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-04 20:58:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-04 20:58:30 -0400 |
commit | d91215d418bfbaa22eb973a9a67cc2aa6aa8ac6b (patch) | |
tree | 10a25233c4cf65eac8c2ee75acbf9759f3b58124 /ext/node/polyfills/_fs | |
parent | f396b3d1c8aaa7bf40fb1960f9ec81c3708ea2a8 (diff) |
fix: revert accidentally added `parentPath` on `DirEntry` (#24438)
Reverts the accidentally added `.parentPath` on dir entries in
https://github.com/denoland/deno/pull/24257/files
This should not have been added to the public api and is not documented.
Diffstat (limited to 'ext/node/polyfills/_fs')
-rw-r--r-- | ext/node/polyfills/_fs/_fs_dirent.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/_fs/_fs_readdir.ts | 10 |
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)); } |