From 209b2868131f43e1707fc706805a270a2b73d45a Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 19 Jun 2024 12:51:01 +0530 Subject: fix(ext/node): Add Dirent.path and Dirent.parentPath (#24257) --- ext/fs/interface.rs | 1 + ext/fs/std_fs.rs | 1 + ext/node/polyfills/_fs/_fs_dirent.ts | 9 +++++++++ 3 files changed, 11 insertions(+) (limited to 'ext') diff --git a/ext/fs/interface.rs b/ext/fs/interface.rs index 5031dc134..833f362bf 100644 --- a/ext/fs/interface.rs +++ b/ext/fs/interface.rs @@ -72,6 +72,7 @@ pub enum FsFileType { #[derive(Serialize)] #[serde(rename_all = "camelCase")] pub struct FsDirEntry { + pub parent_path: String, pub name: String, pub is_file: bool, pub is_directory: bool, diff --git a/ext/fs/std_fs.rs b/ext/fs/std_fs.rs index 9e2acedcc..054f5c9c4 100644 --- a/ext/fs/std_fs.rs +++ b/ext/fs/std_fs.rs @@ -785,6 +785,7 @@ fn read_dir(path: &Path) -> FsResult> { }; } Some(FsDirEntry { + parent_path: path.to_string_lossy().to_string(), name, is_file: method_or_false!(is_file), is_directory: method_or_false!(is_dir), diff --git a/ext/node/polyfills/_fs/_fs_dirent.ts b/ext/node/polyfills/_fs/_fs_dirent.ts index 155d5cb03..0f80fc135 100644 --- a/ext/node/polyfills/_fs/_fs_dirent.ts +++ b/ext/node/polyfills/_fs/_fs_dirent.ts @@ -43,4 +43,13 @@ export default class Dirent { get name(): string | null { return this.entry.name; } + + get parentPath(): string { + return this.entry.parentPath; + } + + /** @deprecated */ + get path(): string { + return this.parentPath; + } } -- cgit v1.2.3