fs.walk()
should return relative paths, not absolute paths.
#3456
Labels
fs.walk()
should return relative paths, not absolute paths.
#3456
Describe the bug
The current implementation of
walk()
withfollowSymlinks = true
seems toaggressively use
realPath()
. This is clearly the intended behavior based onthe unit tests.
However, I think this is not the correct behavior. This is unusual behavior because it defeats
the purpose of symlinks. That is, links to directories and files should appear
to be children of the parent, even if their real location is not. I've never
seen a Unix application implicitly resolve and return a symlink'd absolute path.
This is exacerbated by the fact that
realPath()
throws an exception if thethe destination does not exist #3452 .
@Liamolucko Can you explain the reasoning for using
Deno.realPath()
?07be715#diff-820780ce193d0f4f9a9fd1f227979578c2d5607a43f40d3fb5c6eddd629f6af2R114
Steps to Reproduce
An example use case for when the relative path would be desired would be:
Result:
Expected behavior
The resulting file is
/tmp/flattened/tmp-dest-a.txt
instead of/tmp/flattened/x-y-z-a.txt
.In the above example, I have no way of knowing that
/tmp/test/x/y/z/a.txt
existsor where
tmp-dest-a.txt
came from because it was already resolved. I wouldexpect the
entry.path
to be relative to the parent directory and to be ableto call
Deno.realPath()
on my own if I wanted to resolve the symlink.It would also be nice if
{ path: "/tmp/test/x/y/z/a.txt", isFile: true, isSymlink: true, ... }
included
target: "../../../../dest/a.txt"
.Environment
The text was updated successfully, but these errors were encountered: