Skip to content

Commit d9540b5

Browse files
committed
fs: remove dirent.path
PR-URL: #55548 Fixes: #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>
1 parent 8a29648 commit d9540b5

File tree

8 files changed

+10
-52
lines changed

8 files changed

+10
-52
lines changed

benchmark/fs/bench-opendirSync.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tmpdir.refresh();
88

99
const testFiles = fs.readdirSync('test', { withFileTypes: true })
1010
.filter((f) => f.isDirectory())
11-
.map((f) => path.join(f.path, f.name));
11+
.map((f) => path.join(f.parentPath, f.name));
1212
const bench = common.createBenchmark(main, {
1313
type: ['existing', 'non-existing'],
1414
n: [1e3],

doc/api/deprecations.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -3615,6 +3615,9 @@ Please use `value instanceof WebAssembly.Module` instead.
36153615

36163616
<!-- YAML
36173617
changes:
3618+
- version: REPLACEME
3619+
pr-url: https://github.com/nodejs/node/pull/55548
3620+
description: End-of-Life.
36183621
- version: v23.0.0
36193622
pr-url: https://github.com/nodejs/node/pull/51050
36203623
description: Runtime deprecation.
@@ -3626,9 +3629,9 @@ changes:
36263629
description: Documentation-only deprecation.
36273630
-->
36283631

3629-
Type: Runtime
3632+
Type: End-of-Life
36303633

3631-
The [`dirent.path`][] is deprecated due to its lack of consistency across
3634+
The `dirent.path` property has been removed due to its lack of consistency across
36323635
release lines. Please use [`dirent.parentPath`][] instead.
36333636

36343637
### DEP0179: `Hash` constructor
@@ -3813,7 +3816,6 @@ It is recommended to use the `new` qualifier instead. This applies to all REPL c
38133816
[`diagnostics_channel.subscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelsubscribename-onmessage
38143817
[`diagnostics_channel.unsubscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelunsubscribename-onmessage
38153818
[`dirent.parentPath`]: fs.md#direntparentpath
3816-
[`dirent.path`]: fs.md#direntpath
38173819
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
38183820
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
38193821
[`domain`]: domain.md

doc/api/fs.md

-26
Original file line numberDiff line numberDiff line change
@@ -6811,31 +6811,6 @@ added:
68116811
68126812
The path to the parent directory of the file this {fs.Dirent} object refers to.
68136813
6814-
#### `dirent.path`
6815-
6816-
<!-- YAML
6817-
added:
6818-
- v20.1.0
6819-
- v18.17.0
6820-
deprecated:
6821-
- v21.5.0
6822-
- v20.12.0
6823-
- v18.20.0
6824-
changes:
6825-
- version: v23.2.0
6826-
pr-url: https://github.com/nodejs/node/pull/55547
6827-
description: The property is no longer read-only.
6828-
- version: v23.0.0
6829-
pr-url: https://github.com/nodejs/node/pull/51050
6830-
description: Accessing this property emits a warning. It is now read-only.
6831-
-->
6832-
6833-
> Stability: 0 - Deprecated: Use [`dirent.parentPath`][] instead.
6834-
6835-
* {string}
6836-
6837-
Alias for `dirent.parentPath`.
6838-
68396814
### Class: `fs.FSWatcher`
68406815
68416816
<!-- YAML
@@ -8394,7 +8369,6 @@ the file contents.
83948369
[`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
83958370
[`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw
83968371
[`UV_THREADPOOL_SIZE`]: cli.md#uv_threadpool_sizesize
8397-
[`dirent.parentPath`]: #direntparentpath
83988372
[`event ports`]: https://illumos.org/man/port_create
83998373
[`filehandle.createReadStream()`]: #filehandlecreatereadstreamoptions
84008374
[`filehandle.createWriteStream()`]: #filehandlecreatewritestreamoptions

lib/internal/fs/utils.js

-13
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const {
4949
once,
5050
deprecate,
5151
isWindows,
52-
setOwnProperty,
5352
} = require('internal/util');
5453
const { toPathIfFileURL } = require('internal/url');
5554
const {
@@ -210,18 +209,6 @@ for (const name of ReflectOwnKeys(Dirent.prototype)) {
210209
};
211210
}
212211

213-
ObjectDefineProperty(Dirent.prototype, 'path', {
214-
__proto__: null,
215-
get: deprecate(function() {
216-
return this.parentPath;
217-
}, 'dirent.path is deprecated in favor of dirent.parentPath', 'DEP0178'),
218-
set(value) {
219-
setOwnProperty(this, 'path', value);
220-
},
221-
configurable: true,
222-
enumerable: false,
223-
});
224-
225212
function copyObject(source) {
226213
const target = {};
227214
for (const key in source)

test/parallel/test-fs-opendir.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ const invalidCallbackObj = {
4848
const entries = files.map(() => {
4949
const dirent = dir.readSync();
5050
assertDirent(dirent);
51-
return { name: dirent.name, path: dirent.path, parentPath: dirent.parentPath, toString() { return dirent.name; } };
51+
return { name: dirent.name, parentPath: dirent.parentPath, toString() { return dirent.name; } };
5252
}).sort();
5353
assert.deepStrictEqual(entries.map((d) => d.name), files);
54-
assert.deepStrictEqual(entries.map((d) => d.path), Array(entries.length).fill(testDir));
5554
assert.deepStrictEqual(entries.map((d) => d.parentPath), Array(entries.length).fill(testDir));
5655

5756
// dir.read should return null when no more entries exist

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,7 @@ const filename = 'foo';
100100
common.mustCall((err, dirent) => {
101101
assert.strictEqual(err, null);
102102
assert.strictEqual(dirent.name, filenameBuffer);
103-
common.expectWarning(
104-
'DeprecationWarning',
105-
'dirent.path is deprecated in favor of dirent.parentPath',
106-
'DEP0178');
107-
assert.deepStrictEqual(dirent.path, Buffer.from(tmpdir.resolve(`${filename}/`)));
103+
assert.deepStrictEqual(dirent.parentPath, Buffer.from(tmpdir.resolve(`${filename}/`)));
108104
},
109105
));
110106
}

test/sequential/test-fs-opendir-recursive.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ for (let i = 0; i < expected.length; i++) {
128128
}
129129

130130
function getDirentPath(dirent) {
131-
return pathModule.relative(testDir, pathModule.join(dirent.path, dirent.name));
131+
return pathModule.relative(testDir, pathModule.join(dirent.parentPath, dirent.name));
132132
}
133133

134134
function assertDirents(dirents) {

test/sequential/test-fs-readdir-recursive.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ for (let i = 0; i < expected.length; i++) {
127127
}
128128

129129
function getDirentPath(dirent) {
130-
return pathModule.relative(readdirDir, pathModule.join(dirent.path, dirent.name));
130+
return pathModule.relative(readdirDir, pathModule.join(dirent.parentPath, dirent.name));
131131
}
132132

133133
function assertDirents(dirents) {

0 commit comments

Comments
 (0)