mihneadb / node-directory-tree

Convert a directory tree to a JS object.
MIT License
523 stars 106 forks source link

Does not return Symlinks #127

Closed devpixde closed 1 year ago

devpixde commented 1 year ago

Is there a way to return Symlinks to files? I need a tree that returns Symlinks the same way as files. Is there an option to achieve this?

Strangely i get Symlinks in case there is a hardlink to the same file (with other name) in same directory.

PS: I found the option "followSymlinks" in code, but it seems to handle only directory Symlinks. Symlinks to files seem to be ignored.

mihneadb commented 1 year ago

Hi! It might be that similar to isFile() here, there might be a need to handle something for symlinks.

devpixde commented 1 year ago

line 64 try { stats = FS.statSync(path); lstat = FS.lstatSync(path); } catch (e) { return null } if path is a Symlink to a file we get an error here and return null for the item.

Btw.: I am on MacOS, may not be a problem with other os, not sure about that. Will try to fix it later...

devpixde commented 1 year ago

Problem was that i did not have proper symlinks. They where created with relative paths, which does not work in this case. If i use absolute paths symlinks to files are handled just like files.