Files can incorrectly be nested inside other files
It's possible to read/write files nested inside other files:
const { fs } = require('memfs');
fs.writeFileSync('/foo', 'hello');
fs.writeFileSync('/foo/bar', 'world');
console.log(fs.readFileSync('/foo', 'utf8')); // logs 'hello'
console.log(fs.readFileSync('/foo/bar', 'utf8')); // logs 'world'
console.log(fs.statSync('/foo').isFile()); // logs 'true'
console.log(fs.statSync('/foo').isDirectory()); // logs 'false'
console.log(fs.readdirSync('/foo')); // throws ENOTDIR
/foo is a regular file, and bar is also a regular file that's nested in /foo.
Tested with v4.11.1
Yup that's a bug alright
Hi @NotWearingPants, I think I may be able to help with this issue. I would love to be assigned to it if possible!
@Kenny4297 go for it!
@G-Rath This is fixed in 4.12.0. This issue can be closed now, as well as #1052.
@BadIdeaException do you know if we've got a test to guard against future regression?
Yes, we do: openSync.test.ts tests this exact scenario.
(For future reference: this issue was fixed by #1059)