Is there a way to check whether a file exists in NodeJS, with case-sensitivity, even when the underlying file system isn't case sensitive?
fs.exists() may or may not be case sensitive depending on the underlying file system.
fs = require('fs');
fs.existsSync('readme.txt') // true
fs.existsSync('README.TXT') // false (or true, depending on the file system)
This causes problems when developing an app on a case-insensitive development environment that will be deployed on a case-sensitive server. I recently had an issue where the build was broken by a typo. It worked locally.
If I can get Node to tell me, "yes, README.TXT
exists, and it's stored as readme.txt
" that will be enough to solve the problem.