`readdir` with `withFileTypes:true` incorrectly includes file name in `path`
ziacik opened this issue ยท 2 comments
ziacik commented
The test here
is wrong - node.js actually doesn't include the file name in the path.
So the expectation should be
{ mode: 33206, name: 'af1', path: '/z' },
zzzzBov commented
I just ran into the same issue.
Looks like the Dirent.path
property is being set to the full path, rather than the parent path:
Line 18 in 6f4e72e
Note how Link.getPath
includes the name:
Lines 408 to 414 in 6f4e72e
I think it'd make sense to add a getParentPath()
method to Link
along the lines of:
getParentPath(): string {
return this.steps.slice(0, -1).join(SEP);
}
so that the path assignment in Dirent could be updated to:
dirent.path = link.getParentPath();
G-Rath commented
PRs are welcome ๐