From a990e8fec8149d008efe5b8681873bb4983386e0 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 2 Dec 2023 23:49:21 +0100 Subject: [PATCH 1/7] 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 | 13 +++++++++++++ lib/fs.js | 2 +- lib/internal/fs/utils.js | 1 + test/parallel/test-fs-opendir.js | 8 +++++--- 4 files changed, 20 insertions(+), 4 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` + + + + + + +### DEP0178: `dirent.path` + + + +Type: Documentation-only + +The [`dirent.path`][] is deprecated due to its lack of consistency across +release lines. Please use [`dirent.parentPath`][] instead. + [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 [RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4 @@ -3366,6 +3387,8 @@ In a future version of Node.js, [`message.headers`][], [`decipher.setAuthTag()`]: crypto.md#deciphersetauthtagbuffer-encoding [`diagnostics_channel.subscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelsubscribename-onmessage [`diagnostics_channel.unsubscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelunsubscribename-onmessage +[`dirent.parentPath`]: fs.md#direntparentpath +[`dirent.path`]: fs.md#direntpath [`dns.lookup()`]: dns.md#dnslookuphostname-options-callback [`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options [`domain`]: domain.md From 99ac462aef8e2bef188c80889e7e17e0f1f260c9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 5 Dec 2023 22:15:23 +0100 Subject: [PATCH 6/7] doc: add deprecation notice to `dirent.path` Refs: https://github.com/nodejs/node/pull/51020 PR-URL: https://github.com/nodejs/node/pull/51059 Reviewed-By: Debadree Chatterjee Reviewed-By: Luigi Pinca Reviewed-By: Moshe Atlow --- doc/api/fs.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index d6ac052b3c9f04..6c5944878e0ebf 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -6454,8 +6454,11 @@ The path to the parent directory of the file this {fs.Dirent} object refers to. +> Stability: 0 - Deprecated: Use [`dirent.parentPath`][] instead. + * {string} The base path that this {fs.Dirent} object refers to. @@ -7995,6 +7998,7 @@ the file contents. [`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER [`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw [`UV_THREADPOOL_SIZE`]: cli.md#uv_threadpool_sizesize +[`dirent.parentPath`]: #direntparentpath [`event ports`]: https://illumos.org/man/port_create [`filehandle.createReadStream()`]: #filehandlecreatereadstreamoptions [`filehandle.createWriteStream()`]: #filehandlecreatewritestreamoptions From 650888ee5803d0662e7cd680381673b2bcade3f7 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 6 Dec 2023 00:28:02 +0100 Subject: [PATCH 7/7] fixup! doc: deprecate `dirent.path` --- doc/api/deprecations.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index e5e36c7cef6a39..5ed95d9dcf8f5a 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3322,10 +3322,15 @@ In a future version of Node.js, [`message.headers`][], [`message.trailersDistinct`][] will be read-only. + + + + + ### DEP0178: `dirent.path`