Open papb opened 4 years ago
The problem as you described it, is that there is a file on disk where your path expects directory. Returning false
in that case can be misleading, because you just can't create directory or file on path a/b
. Technically yes, this file doesn't exist, but more important is that the path is invalid for current state of files on disk. I'd say it should throw.
The problem is rooted in windows operating system itself: https://github.com/nodejs/node/issues/18014
You can check it manually, but this check seems to be time-consuming and will fire also when path is valid, but doesn't exist. Maybe I'll tacle it as better, coherent behaviour across whole API, not only in exists
case. Need to think more.
This gives
false
on Windows, but gives an error in Linux:I see meaning in both behaviors, but I think one of them should be chosen so that
fs-jetpack
behaves consistently on this across platforms.In my use-case, I wanted
false
in both cases, but I can see meaning in getting an error as well. I am not sure which behavior to suggest.Regardless, I worked around this with a try-catch, so don't rush about it. Just letting you know.