Support for case sensitivity settings
Hi! As you probably know, there are 2 options for case sensitivity:
- Windows use case sensitive paths,
- other systems like macOS or Linux use case insensitive paths
I checked how memfs behave and it seems that it uses case sensitive approach:
const { fs } = require('memfs');
fs.writeFileSync('/my/Case/sensitive/Path.txt', 'content');
console.log(fs.readFileSync('/my/case/sensitive/path.txt'));
// logs undefined
// if I would use native fs on macOS or Linux, I would get "content" logged
// so it's kind of inconsistency between memfs and fs
It would be nice if:
- there would be an option to configure it
- the default behavior would be to use system settings
- there would be an option to configure it
Yes, it seems we could add support for case insensitive paths.
- the default behavior would be to use system settings
I'm not sure if memfs should "magically" change the way it handles paths; I would prefer it is set explicitly. But happy to hear opinions.
I might be missing something, but:
As you probably know, there are 2 options for case sensitivity:
The OSs act the opposite way around from your list: Windows is case insensitive, while UNIX is case sensitive.

I'm not sure if memfs should "magically" change the way it handles paths
For now I agree with that - I think memfs should be careful adopting "magical" features since they tend to be very "gain this, lose that", but an explicit option could work.
I think in this case actually the OS side should be ignored, since the reason why fs is/isnt case-sensitive is because of the underlying OS/FS rather than node; aka it's not Node going "oh you're on Linux" and changing its behaviour; it's instead a result of the underlying API calls V8 makes to the native file system, which behaves accordingly.
Because of that, I think you could make a case for saying something like having the current behavior being the "default", and then implementing a ignoreCase option that causes memfs to just call toLowerCase on everything?
On an aside: I think memfs should probably favor defaulting to unix behaviours since it already uses the unix file path format (i.e /my/path/ instead of C:\my\path).
That way you'd be less surprised - i.e if we had ignoreCase be based on the OS, then it would make it reasonable to also assume you could use C:\my\path when running on Windows, which you can't.
I might be missing something, but:
As you probably know, there are 2 options for case sensitivity:
The OSs act the opposite way around from your list: Windows is case insensitive, while UNIX is case sensitive.
Yes, I was wrong about Windows, but still, macOS is case-insensitive 😃
Because of that, I think you could make a case for saying something like having the current behavior being the "default", and then implementing a ignoreCase option that causes memfs to just call toLowerCase on everything?
Yes, Implementing it just as a configuration option would be enough 👍
macOS is case-insensitive
Interesting, that is very useful to know given that most of our devs at work are on macs while our servers are Ubuntu 😄 😬
Is it something that I could expect to be implemented by one of the maintainers, or you would like to get a PR from me? 😃
@piotr-oles PR from you :)
Turns out this is not that hard to implement. I opened #632 to make case sensitivity configurable.