mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
fs: make dirent.path writable
PR-URL: https://github.com/nodejs/node/pull/55547 Refs: https://github.com/nodejs/node/issues/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>
This commit is contained in:
1 parent
fa61dced44
commit
f628fc43cb
3 files changed
+20
-1
No files matched your search
+4
-1
@@ -6822,6 +6822,9 @@ deprecated:
|
||||
- v20.12.0
|
||||
- v18.20.0
|
||||
changes:
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/55547
|
||||
description: The property is no longer read-only.
|
||||
- version: v23.0.0
|
||||
pr-url: https://github.com/nodejs/node/pull/51050
|
||||
description: Accessing this property emits a warning. It is now read-only.
|
||||
@@ -6831,7 +6834,7 @@ changes:
|
||||
|
||||
* {string}
|
||||
|
||||
Alias for `dirent.parentPath`. Read-only.
|
||||
Alias for `dirent.parentPath`.
|
||||
|
||||
### Class: `fs.FSWatcher`
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ const {
|
||||
once,
|
||||
deprecate,
|
||||
isWindows,
|
||||
setOwnProperty,
|
||||
} = require('internal/util');
|
||||
const { toPathIfFileURL } = require('internal/url');
|
||||
const {
|
||||
@@ -214,6 +215,9 @@ ObjectDefineProperty(Dirent.prototype, 'path', {
|
||||
get: deprecate(function() {
|
||||
return this.parentPath;
|
||||
}, 'dirent.path is deprecated in favor of dirent.parentPath', 'DEP0178'),
|
||||
set(value) {
|
||||
setOwnProperty(this, 'path', value);
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
});
|
||||
|
||||
@@ -78,6 +78,18 @@ const filename = 'foo';
|
||||
},
|
||||
));
|
||||
}
|
||||
{
|
||||
// Reassigning `.path` property should not trigger a warning
|
||||
const dirent = getDirent(
|
||||
tmpdir.path,
|
||||
filename,
|
||||
UV_DIRENT_UNKNOWN,
|
||||
);
|
||||
assert.strictEqual(dirent.name, filename);
|
||||
dirent.path = 'some other value';
|
||||
assert.strictEqual(dirent.parentPath, tmpdir.path);
|
||||
assert.strictEqual(dirent.path, 'some other value');
|
||||
}
|
||||
{
|
||||
// string + Buffer
|
||||
const filenameBuffer = Buffer.from(filename);
|
||||
|
||||
Reference in new issue
Block a user