From 2e458d973638d01fcb6a0d7d611e0120a94f4d35 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 2 Dec 2023 23:49:21 +0100 Subject: [PATCH] fs: introduce `dirent.parentPath` The goal is to replace `dirent.path` using a name that's less likely to create confusion. `dirent.path` value has not been stable, moving it to a different property name should avoid breaking some upgrading user expectations. PR-URL: https://github.com/nodejs/node/pull/50976 Reviewed-By: Ethan Arrowood Reviewed-By: LiviaMedeiros --- doc/api/fs.md | 15 ++++++++++++++- lib/fs.js | 2 +- lib/internal/fs/dir.js | 2 +- lib/internal/fs/utils.js | 1 + test/parallel/test-fs-opendir.js | 8 +++++--- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index be9acd7dad7a35..17ff809f328bfb 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -6638,6 +6638,19 @@ The file name that this {fs.Dirent} object refers to. The type of this value is determined by the `options.encoding` passed to [`fs.readdir()`][] or [`fs.readdirSync()`][]. +#### `dirent.parentPath` + + + +> Stability: 1 – Experimental + +* {string} + +The path to the parent directory of the file this {fs.Dirent} object refers to. + #### `dirent.path`