Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f628fc4

Browse filesBrowse files
aduh95RafaelGSS
authored andcommitted
fs: make dirent.path writable
PR-URL: #55547 Refs: #55538 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent fa61dce commit f628fc4
Copy full SHA for f628fc4

File tree

Expand file treeCollapse file tree

3 files changed

+20
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+20
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/fs.md‎

Copy file name to clipboardExpand all lines: doc/api/fs.md
+4-1Lines changed: 4 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -6822,6 +6822,9 @@ deprecated:
68226822
- v20.12.0
68236823
- v18.20.0
68246824
changes:
6825+
- version: REPLACEME
6826+
pr-url: https://github.com/nodejs/node/pull/55547
6827+
description: The property is no longer read-only.
68256828
- version: v23.0.0
68266829
pr-url: https://github.com/nodejs/node/pull/51050
68276830
description: Accessing this property emits a warning. It is now read-only.
@@ -6831,7 +6834,7 @@ changes:
68316834
68326835
* {string}
68336836
6834-
Alias for `dirent.parentPath`. Read-only.
6837+
Alias for `dirent.parentPath`.
68356838
68366839
### Class: `fs.FSWatcher`
68376840
Collapse file

‎lib/internal/fs/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/utils.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const {
4949
once,
5050
deprecate,
5151
isWindows,
52+
setOwnProperty,
5253
} = require('internal/util');
5354
const { toPathIfFileURL } = require('internal/url');
5455
const {
@@ -214,6 +215,9 @@ ObjectDefineProperty(Dirent.prototype, 'path', {
214215
get: deprecate(function() {
215216
return this.parentPath;
216217
}, 'dirent.path is deprecated in favor of dirent.parentPath', 'DEP0178'),
218+
set(value) {
219+
setOwnProperty(this, 'path', value);
220+
},
217221
configurable: true,
218222
enumerable: false,
219223
});
Collapse file

‎test/parallel/test-fs-utils-get-dirents.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-utils-get-dirents.js
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ const filename = 'foo';
7878
},
7979
));
8080
}
81+
{
82+
// Reassigning `.path` property should not trigger a warning
83+
const dirent = getDirent(
84+
tmpdir.path,
85+
filename,
86+
UV_DIRENT_UNKNOWN,
87+
);
88+
assert.strictEqual(dirent.name, filename);
89+
dirent.path = 'some other value';
90+
assert.strictEqual(dirent.parentPath, tmpdir.path);
91+
assert.strictEqual(dirent.path, 'some other value');
92+
}
8193
{
8294
// string + Buffer
8395
const filenameBuffer = Buffer.from(filename);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.