fs: runtime deprecate dirent.path
PR-URL: https://github.com/nodejs/node/pull/51050 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
This commit is contained in:
parent
77db3911be
commit
15e7563062
@ -3554,6 +3554,9 @@ Please use `value instanceof WebAssembly.Module` instead.
|
|||||||
|
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/51050
|
||||||
|
description: Runtime deprecation.
|
||||||
- version:
|
- version:
|
||||||
- v21.5.0
|
- v21.5.0
|
||||||
- v20.12.0
|
- v20.12.0
|
||||||
@ -3562,7 +3565,7 @@ changes:
|
|||||||
description: Documentation-only deprecation.
|
description: Documentation-only deprecation.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Type: Documentation-only
|
Type: Runtime
|
||||||
|
|
||||||
The [`dirent.path`][] is deprecated due to its lack of consistency across
|
The [`dirent.path`][] is deprecated due to its lack of consistency across
|
||||||
release lines. Please use [`dirent.parentPath`][] instead.
|
release lines. Please use [`dirent.parentPath`][] instead.
|
||||||
|
@ -6763,13 +6763,17 @@ deprecated:
|
|||||||
- v21.5.0
|
- v21.5.0
|
||||||
- v20.12.0
|
- v20.12.0
|
||||||
- v18.20.0
|
- v18.20.0
|
||||||
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/51050
|
||||||
|
description: Accessing this property emits a warning. It is now read-only.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
> Stability: 0 - Deprecated: Use [`dirent.parentPath`][] instead.
|
> Stability: 0 - Deprecated: Use [`dirent.parentPath`][] instead.
|
||||||
|
|
||||||
* {string}
|
* {string}
|
||||||
|
|
||||||
Alias for `dirent.parentPath`.
|
Alias for `dirent.parentPath`. Read-only.
|
||||||
|
|
||||||
### Class: `fs.FSWatcher`
|
### Class: `fs.FSWatcher`
|
||||||
|
|
||||||
|
@ -166,7 +166,6 @@ class Dirent {
|
|||||||
constructor(name, type, path) {
|
constructor(name, type, path) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.parentPath = path;
|
this.parentPath = path;
|
||||||
this.path = path;
|
|
||||||
this[kType] = type;
|
this[kType] = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +214,15 @@ for (const name of ReflectOwnKeys(Dirent.prototype)) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjectDefineProperty(Dirent.prototype, 'path', {
|
||||||
|
__proto__: null,
|
||||||
|
get: deprecate(function() {
|
||||||
|
return this.parentPath;
|
||||||
|
}, 'dirent.path is deprecated in favor of dirent.parentPath', 'DEP0178'),
|
||||||
|
configurable: true,
|
||||||
|
enumerable: false,
|
||||||
|
});
|
||||||
|
|
||||||
function copyObject(source) {
|
function copyObject(source) {
|
||||||
const target = {};
|
const target = {};
|
||||||
for (const key in source)
|
for (const key in source)
|
||||||
|
@ -88,6 +88,11 @@ const filename = 'foo';
|
|||||||
common.mustCall((err, dirent) => {
|
common.mustCall((err, dirent) => {
|
||||||
assert.strictEqual(err, null);
|
assert.strictEqual(err, null);
|
||||||
assert.strictEqual(dirent.name, filenameBuffer);
|
assert.strictEqual(dirent.name, filenameBuffer);
|
||||||
|
common.expectWarning(
|
||||||
|
'DeprecationWarning',
|
||||||
|
'dirent.path is deprecated in favor of dirent.parentPath',
|
||||||
|
'DEP0178');
|
||||||
|
assert.deepStrictEqual(dirent.path, Buffer.from(tmpdir.resolve(`${filename}/`)));
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user