Sha256: 148eaf26d8d2452912d3db96338386c233b3eed56c7f1d70f53df0d5244db240

Contents?: true

Size: 1.89 KB

Versions: 32

Compression:

Stored size: 1.89 KB

Contents

# true-case-path

## Usage

`trueCasePathSync(<fileSystemPath>)`

## Description

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.

## Platforms

Windows, OSX, and Linux (though note the limitations with case-insensitive filesystems).

## Limitations

- Paths starting with `'./'` 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.
- On Windows, no attempt is made to case-correct the drive letter or UNC-share
  component of the path.
- Unicode support:
  - Be sure to use UTF8 source-code files (with a BOM on Windows)
  - On OSX, the input path is automatically converted to NFD Unicode form
    to match how the filesystem stores names, but note that the result will
    invariably be NFD too (which makes no difference for ASCII-characters-only
    names).

## Examples

```
const trueCasePathSync = require('true-case-path')

trueCasePathSync('/users/guest') // OSX: -> '/Users/Guest'

trueCasePathSync('c:\\users\\all users') // Windows: -> 'c:\Users\All Users'
```

## Attribution

The code for this project was sourced from [http://stackoverflow.com/a/33139702/45375](http://stackoverflow.com/a/33139702/45375)

Version data entries

32 entries across 31 versions & 12 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/true-case-path/README.md
disco_app-0.18.0 test/dummy/node_modules/true-case-path/README.md
disco_app-0.18.2 test/dummy/node_modules/true-case-path/README.md
tang-0.2.1 spec/tang_app/node_modules/true-case-path/README.md
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/true-case-path/README.md
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/true-case-path/README.md
ruby2js-4.0.4 lib/tasks/testrails/node_modules/true-case-path/README.md
ruby2js-4.0.3 lib/tasks/testrails/node_modules/true-case-path/README.md
tang-0.2.0 spec/tang_app/node_modules/true-case-path/README.md
tang-0.1.0 spec/tang_app/node_modules/true-case-path/README.md
tang-0.0.9 spec/tang_app/node_modules/true-case-path/README.md
enju_library-0.3.8 spec/dummy/node_modules/true-case-path/README.md
ilog-0.4.1 node_modules/true-case-path/README.md
ilog-0.4.0 node_modules/true-case-path/README.md
ilog-0.3.3 node_modules/true-case-path/README.md
jester-data-8.0.0 node_modules/true-case-path/README.md
ezii-os-5.2.1 node_modules/true-case-path/README.md
ezii-os-2.0.1 node_modules/true-case-path/README.md
ezii-os-1.1.0 node_modules/true-case-path/README.md
ezii-os-1.0.0 node_modules/true-case-path/README.md