I noticed that the official node documentation says something startling about fs.exists
:
\"fs.exists() is an anachronism and exists only
Being deprecated because it's an anti-pattern according to some. I.e. it's not safe to trust exists() and then doing something with the file because the file can be removed in between the exists-call and the doing-something-call.
I agree in the above case. But to me, there is more use of exists(). I place empty dummy files in my temp- and cache directories. When I perform dangerous operations, such as removing old files from the cache dir I look for my dummy file to ensure that I'm not operating in the wrong directory. I.e. I just need to confirm that the file is there. Exists suits the bill perfectly for this, but I guess I'll switch to using stat() instead.