Skip to content

Commit

Permalink
fs: remove dirent.path
Browse files Browse the repository at this point in the history
PR-URL: #55548
Fixes: #55538
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: LiviaMedeiros <[email protected]>
Reviewed-By: Ethan Arrowood <[email protected]>
  • Loading branch information
aduh95 committed Nov 14, 2024
1 parent 8a29648 commit d224cf4
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 52 deletions.
2 changes: 1 addition & 1 deletion benchmark/fs/bench-opendirSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tmpdir.refresh();

const testFiles = fs.readdirSync('test', { withFileTypes: true })
.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, {
type: ['existing', 'non-existing'],
n: [1e3],
Expand Down
8 changes: 5 additions & 3 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3615,6 +3615,9 @@ Please use `value instanceof WebAssembly.Module` instead.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/55548
description: End-of-Life.
- version: v23.0.0
pr-url: https://github.com/nodejs/node/pull/51050
description: Runtime deprecation.
Expand All @@ -3626,9 +3629,9 @@ changes:
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.

### DEP0179: `Hash` constructor
Expand Down Expand Up @@ -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.unsubscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelunsubscribename-onmessage
[`dirent.parentPath`]: fs.md#direntparentpath
[`dirent.path`]: fs.md#direntpath
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
[`domain`]: domain.md
Expand Down
26 changes: 0 additions & 26 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6811,31 +6811,6 @@ added:
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`
<!-- YAML
Expand Down Expand Up @@ -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
[`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw
[`UV_THREADPOOL_SIZE`]: cli.md#uv_threadpool_sizesize
[`dirent.parentPath`]: #direntparentpath
[`event ports`]: https://illumos.org/man/port_create
[`filehandle.createReadStream()`]: #filehandlecreatereadstreamoptions
[`filehandle.createWriteStream()`]: #filehandlecreatewritestreamoptions
Expand Down
13 changes: 0 additions & 13 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const {
once,
deprecate,
isWindows,
setOwnProperty,
} = require('internal/util');
const { toPathIfFileURL } = require('internal/url');
const {
Expand Down Expand Up @@ -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) {
const target = {};
for (const key in source)
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-fs-opendir.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ const invalidCallbackObj = {
const entries = files.map(() => {
const dirent = dir.readSync();
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();
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));

// dir.read should return null when no more entries exist
Expand Down
6 changes: 1 addition & 5 deletions test/parallel/test-fs-utils-get-dirents.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ const filename = 'foo';
common.mustCall((err, dirent) => {
assert.strictEqual(err, null);
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}/`)));
assert.deepStrictEqual(dirent.parentPath, Buffer.from(tmpdir.resolve(`${filename}/`)));
},
));
}
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-fs-opendir-recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ for (let i = 0; i < expected.length; i++) {
}

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) {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-fs-readdir-recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ for (let i = 0; i < expected.length; i++) {
}

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) {
Expand Down

0 comments on commit d224cf4

Please sign in to comment.