sindresorhus/trash

fs.lstatSync throws when file doesn't exist.

jdalton opened this issue · 5 comments

With the addition of using fs.lstatSync
126a1dd, now trash errors with

Error: ENOENT: no such file or directory, lstat './the-file'
   at Object.fs.lstatSync 

When a file doesn't exist, where as fs.existsSync would return false.

Related to #64 (\cc @jdanford)

Wow, I should have caught that – thank you!

@jdanford Np! Is this symlink issue of fs.existsSync (#63) known by Node? It may be something to raise with the Node tracker to see if it can be fixed at the core level.

Many file-related functions transparently follow symlinks, in accordance with the behavior of stat() in POSIX, so fs.existsSync() is doing the right thing here. More importantly, fs.exists() and its synchronous counterpart are now deprecated in favor of using fs.stat() directly, so either way there's no issue!

Cool!

FWIW fs.existsSync is not deprecated, only fs.exists.
(they removed fs.existsSync from deprecation because of its large ecosystem use)

My mistake!