mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
fs: remove dirent.path
PR-URL: https://github.com/nodejs/node/pull/55548 Fixes: https://github.com/nodejs/node/issues/55538 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
This commit is contained in:
parent
8a29648ff5
commit
d9540b51eb
@ -8,7 +8,7 @@ tmpdir.refresh();
|
|||||||
|
|
||||||
const testFiles = fs.readdirSync('test', { withFileTypes: true })
|
const testFiles = fs.readdirSync('test', { withFileTypes: true })
|
||||||
.filter((f) => f.isDirectory())
|
.filter((f) => f.isDirectory())
|
||||||
.map((f) => path.join(f.path, f.name));
|
.map((f) => path.join(f.parentPath, f.name));
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
type: ['existing', 'non-existing'],
|
type: ['existing', 'non-existing'],
|
||||||
n: [1e3],
|
n: [1e3],
|
||||||
|
@ -3615,6 +3615,9 @@ Please use `value instanceof WebAssembly.Module` instead.
|
|||||||
|
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/55548
|
||||||
|
description: End-of-Life.
|
||||||
- version: v23.0.0
|
- version: v23.0.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/51050
|
pr-url: https://github.com/nodejs/node/pull/51050
|
||||||
description: Runtime deprecation.
|
description: Runtime deprecation.
|
||||||
@ -3626,9 +3629,9 @@ changes:
|
|||||||
description: Documentation-only deprecation.
|
description: Documentation-only deprecation.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Type: Runtime
|
Type: End-of-Life
|
||||||
|
|
||||||
The [`dirent.path`][] is deprecated due to its lack of consistency across
|
The `dirent.path` property has been removed due to its lack of consistency across
|
||||||
release lines. Please use [`dirent.parentPath`][] instead.
|
release lines. Please use [`dirent.parentPath`][] instead.
|
||||||
|
|
||||||
### DEP0179: `Hash` constructor
|
### DEP0179: `Hash` constructor
|
||||||
@ -3813,7 +3816,6 @@ It is recommended to use the `new` qualifier instead. This applies to all REPL c
|
|||||||
[`diagnostics_channel.subscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelsubscribename-onmessage
|
[`diagnostics_channel.subscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelsubscribename-onmessage
|
||||||
[`diagnostics_channel.unsubscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelunsubscribename-onmessage
|
[`diagnostics_channel.unsubscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelunsubscribename-onmessage
|
||||||
[`dirent.parentPath`]: fs.md#direntparentpath
|
[`dirent.parentPath`]: fs.md#direntparentpath
|
||||||
[`dirent.path`]: fs.md#direntpath
|
|
||||||
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
|
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
|
||||||
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
|
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
|
||||||
[`domain`]: domain.md
|
[`domain`]: domain.md
|
||||||
|
@ -6811,31 +6811,6 @@ added:
|
|||||||
|
|
||||||
The path to the parent directory of the file this {fs.Dirent} object refers to.
|
The path to the parent directory of the file this {fs.Dirent} object refers to.
|
||||||
|
|
||||||
#### `dirent.path`
|
|
||||||
|
|
||||||
<!-- YAML
|
|
||||||
added:
|
|
||||||
- v20.1.0
|
|
||||||
- v18.17.0
|
|
||||||
deprecated:
|
|
||||||
- v21.5.0
|
|
||||||
- v20.12.0
|
|
||||||
- v18.20.0
|
|
||||||
changes:
|
|
||||||
- version: v23.2.0
|
|
||||||
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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
> Stability: 0 - Deprecated: Use [`dirent.parentPath`][] instead.
|
|
||||||
|
|
||||||
* {string}
|
|
||||||
|
|
||||||
Alias for `dirent.parentPath`.
|
|
||||||
|
|
||||||
### Class: `fs.FSWatcher`
|
### Class: `fs.FSWatcher`
|
||||||
|
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
@ -8394,7 +8369,6 @@ the file contents.
|
|||||||
[`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
|
[`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
|
[`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw
|
||||||
[`UV_THREADPOOL_SIZE`]: cli.md#uv_threadpool_sizesize
|
[`UV_THREADPOOL_SIZE`]: cli.md#uv_threadpool_sizesize
|
||||||
[`dirent.parentPath`]: #direntparentpath
|
|
||||||
[`event ports`]: https://illumos.org/man/port_create
|
[`event ports`]: https://illumos.org/man/port_create
|
||||||
[`filehandle.createReadStream()`]: #filehandlecreatereadstreamoptions
|
[`filehandle.createReadStream()`]: #filehandlecreatereadstreamoptions
|
||||||
[`filehandle.createWriteStream()`]: #filehandlecreatewritestreamoptions
|
[`filehandle.createWriteStream()`]: #filehandlecreatewritestreamoptions
|
||||||
|
@ -49,7 +49,6 @@ const {
|
|||||||
once,
|
once,
|
||||||
deprecate,
|
deprecate,
|
||||||
isWindows,
|
isWindows,
|
||||||
setOwnProperty,
|
|
||||||
} = require('internal/util');
|
} = require('internal/util');
|
||||||
const { toPathIfFileURL } = require('internal/url');
|
const { toPathIfFileURL } = require('internal/url');
|
||||||
const {
|
const {
|
||||||
@ -210,18 +209,6 @@ 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'),
|
|
||||||
set(value) {
|
|
||||||
setOwnProperty(this, 'path', value);
|
|
||||||
},
|
|
||||||
configurable: true,
|
|
||||||
enumerable: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
function copyObject(source) {
|
function copyObject(source) {
|
||||||
const target = {};
|
const target = {};
|
||||||
for (const key in source)
|
for (const key in source)
|
||||||
|
@ -48,10 +48,9 @@ const invalidCallbackObj = {
|
|||||||
const entries = files.map(() => {
|
const entries = files.map(() => {
|
||||||
const dirent = dir.readSync();
|
const dirent = dir.readSync();
|
||||||
assertDirent(dirent);
|
assertDirent(dirent);
|
||||||
return { name: dirent.name, path: dirent.path, parentPath: dirent.parentPath, toString() { return dirent.name; } };
|
return { name: dirent.name, parentPath: dirent.parentPath, toString() { return dirent.name; } };
|
||||||
}).sort();
|
}).sort();
|
||||||
assert.deepStrictEqual(entries.map((d) => d.name), files);
|
assert.deepStrictEqual(entries.map((d) => d.name), files);
|
||||||
assert.deepStrictEqual(entries.map((d) => d.path), Array(entries.length).fill(testDir));
|
|
||||||
assert.deepStrictEqual(entries.map((d) => d.parentPath), Array(entries.length).fill(testDir));
|
assert.deepStrictEqual(entries.map((d) => d.parentPath), Array(entries.length).fill(testDir));
|
||||||
|
|
||||||
// dir.read should return null when no more entries exist
|
// dir.read should return null when no more entries exist
|
||||||
|
@ -100,11 +100,7 @@ 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(
|
assert.deepStrictEqual(dirent.parentPath, Buffer.from(tmpdir.resolve(`${filename}/`)));
|
||||||
'DeprecationWarning',
|
|
||||||
'dirent.path is deprecated in favor of dirent.parentPath',
|
|
||||||
'DEP0178');
|
|
||||||
assert.deepStrictEqual(dirent.path, Buffer.from(tmpdir.resolve(`${filename}/`)));
|
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ for (let i = 0; i < expected.length; i++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDirentPath(dirent) {
|
function getDirentPath(dirent) {
|
||||||
return pathModule.relative(testDir, pathModule.join(dirent.path, dirent.name));
|
return pathModule.relative(testDir, pathModule.join(dirent.parentPath, dirent.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertDirents(dirents) {
|
function assertDirents(dirents) {
|
||||||
|
@ -127,7 +127,7 @@ for (let i = 0; i < expected.length; i++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDirentPath(dirent) {
|
function getDirentPath(dirent) {
|
||||||
return pathModule.relative(readdirDir, pathModule.join(dirent.path, dirent.name));
|
return pathModule.relative(readdirDir, pathModule.join(dirent.parentPath, dirent.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertDirents(dirents) {
|
function assertDirents(dirents) {
|
||||||
|
Loading…
Reference in New Issue
Block a user