Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for case sensitivity settings #533

Open
piotr-oles opened this issue May 6, 2020 · 8 comments
Open

Support for case sensitivity settings #533

piotr-oles opened this issue May 6, 2020 · 8 comments

Comments

@piotr-oles
Copy link

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:

  1. there would be an option to configure it
  2. the default behavior would be to use system settings
@streamich
Copy link
Owner

  1. there would be an option to configure it

Yes, it seems we could add support for case insensitive paths.

  1. 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.

@G-Rath
Copy link
Collaborator

G-Rath commented May 10, 2020

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.

image

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?

@G-Rath
Copy link
Collaborator

G-Rath commented May 10, 2020

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.

@piotr-oles
Copy link
Author

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 👍

@G-Rath
Copy link
Collaborator

G-Rath commented May 12, 2020

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 😄 😬

@piotr-oles
Copy link
Author

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? 😃

@streamich
Copy link
Owner

@piotr-oles PR from you :)

ajafff added a commit to ajafff/memfs that referenced this issue Feb 9, 2021
Defaults to 'true'. If 'false', handle file names case insensitive.
Preserve original file names.

Fixes: streamich#533
@ajafff
Copy link
Contributor

ajafff commented Feb 9, 2021

Turns out this is not that hard to implement. I opened #632 to make case sensitivity configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants