true-case-path
Given a possibly case-variant version of an existing filesystem path, returns the case-exact, normalized version as stored in the filesystem.
Last updated 9 years ago by barsh .
Apache version 2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install true-case-path 
SYNC missed versions from official npm registry.

true-case-path

TravisCI Build Status

Given a possibly case-variant version of an existing filesystem path, returns the absolute, case-exact, normalized version as stored in the filesystem.

Usage

const { trueCasePath, trueCasePathSync } = require('true-case-path')

trueCasePath(<fileSystemPath>)
    .then((caseCorrectPath) => {
        // ...
    })

const caseCorrectPath = trueCasePathSync(<fileSystemPath>)

NOTE: If no matching path exists, an error with be thrown.


Optionally takes a second argument to use as the base path to begin case-correction from. This can be particularly useful within shared hosting environments since true-case-path relies on the ability to list a directory's contents in order to check the case and attempting to list the contents of / or /home will generally result in a permissions error.

const { trueCasePath } = require('true-case-path')

trueCasePath('code/my-app/sOmE-FiLe', '/home/casey')

NOTE: When specifying a basePath, the first argument is expected to be the file path relative to that basePath. If the first argument is absolute, every path segment will be checked. basePath defaults to process.cwd() if not specified and the first argument is relative.

Platforms

Windows, OSX, and Linux

Examples

const { trueCasePathSync } = require('true-case-path')

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

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

Current Tags

  • 2.2.1                                ...           latest (5 years ago)

7 Versions

  • 2.2.1                                ...           5 years ago
  • 2.2.0                                ...           5 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE