Closed elegaanz closed 1 year ago
writeFile will happily write to a path that is currently a directory. The children of the directory will be kept, but its type will become 'file' and thus any subsequent operation will throw ENOTDIR.
writeFile
'file'
ENOTDIR
Here is a minimal example.
import FS from "@isomorphic-git/lightning-fs"; const fs = new FS("demo"); const pfs = fs.promises; const main = async () => { await pfs.mkdir("/foo"); await pfs.writeFile("/foo", "bar"); await pfs.readdir("/foo"); // throws ENOTDIR }; main();
In Node, the following error is thrown by writeFile: Uncaught [Error: EISDIR: illegal operation on a directory, open 'test']
Uncaught [Error: EISDIR: illegal operation on a directory, open 'test']
Thanks for the report, do you want to contribute and throw an error if the path is a directory?
I can try to make a PR in the next days hours, yes.
writeFile
will happily write to a path that is currently a directory. The children of the directory will be kept, but its type will become'file'
and thus any subsequent operation will throwENOTDIR
.Here is a minimal example.
In Node, the following error is thrown by
writeFile
:Uncaught [Error: EISDIR: illegal operation on a directory, open 'test']