From 26e8f7793e7a4132c24af82e181a2de457deed25 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 Backport-PR-URL: https://github.com/nodejs/node/pull/51021 Reviewed-By: Ethan Arrowood Reviewed-By: LiviaMedeiros --- doc/api/fs.md | 13 +++++++++++++ lib/internal/fs/dir.js | 3 ++- lib/internal/fs/utils.js | 23 ++++++++++++++--------- test/parallel/test-fs-opendir.js | 8 +++++--- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index bc2d6b64ca2e51..d6ac052b3c9f04 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -6437,6 +6437,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`