Eric Foster 35b96bc934 initial commit | 6 år sedan | |
---|---|---|
.. | ||
node_modules/glob | 6 år sedan | |
.npmignore | 6 år sedan | |
LICENSE | 6 år sedan | |
README.md | 6 år sedan | |
index.js | 6 år sedan | |
package.json | 6 år sedan |
trueCasePathSync(<fileSystemPath>)
Given a possibly case-variant version of an existing filesystem path, returns the case-exact, normalized version as stored in the filesystem.
If the input path is a globbing pattern as defined by the 'glob' npm package, only the 1st match, if any, is returned. Only a literal input path guarantees an unambiguous result.
If no matching path exists, undefined is returned. On case-SENSITIVE filesystems, a match will also be found, but if case variations of a given path exist, it is undefined which match is returned.
Windows, OSX, and Linux (though note the limitations with case-insensitive filesystems).
'./'
are acceptable, but paths starting with '../'
are not - when in doubt, resolve with fs.realPathSync()
first.
An initial '.'
and interior '..'
instances are normalized, but a relative
input path still results in a relative output path. If you want to ensure
an absolute output path, apply fs.realPathSync()
to the result.const trueCasePathSync = require('true-case-path')
trueCasePathSync('/users/guest') // OSX: -> '/Users/Guest'
trueCasePathSync('c:\\users\\all users') // Windows: -> 'c:\Users\All Users'
The code for this project was sourced from http://stackoverflow.com/a/33139702/45375