-
Notifications
You must be signed in to change notification settings - Fork 774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error message for ensureSymlink if the current existing link is broken #925
Labels
Comments
ping @manidlou |
If you call |
RyanZim
changed the title
ensureSymlink fails if the current existing link is broken
Better error message for ensureSymlink if the current existing link is broken
Oct 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fs-extra
version: 10.0.0I'm not sure if this is the expected behavior.
Here's what I'm trying to do... basically I want to replicate what
ln -sfn
does. I would like to create a link to a file in my home bin folder. If I move the target file to another directory, then as expected, that link will now be broken. That's why I want to recreate that link, updating the target path. The problem is when I do this (callingcreateSymlink
) node throws an error (because the link is broken):The error is thrown by Node when calling
fs.stat
orfs.statSync
, here's what happens when I call it in Node REPL:The link exists, only it's broken. Looks like that is expected behavior for Node because it will call POSIX
stat
, and as the description:However for that purpose we can use
fs.lstat
orfs.lstatSync
which will call POSIXlstat
, which as described:Calling
fs.lstatSync
succeeds:Shouldn't
fs.ensureSymlink
check for broken symlink and update it (given the new target path exists)?The text was updated successfully, but these errors were encountered: