包详细信息

true-case-path

Profiscience8.7mApache-2.02.2.1

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

自述文件

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'

更新日志

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.2.1 (2019-07-24)

Bug Fixes

  • windows: Drive letter bug (1b736b7)

2.2.0 (2019-07-24)

Build System

Features

2.1.0 (2019-07-24)

Build System

Features

2.0.0 (2019-04-26)

Rewrite, transfer to Profiscience GitHub org, set up CI

BREAKING CHANGES

  • Use named exports instead of exporting sync func by default (was 'module.exports = trueCasePathSync, nowmodule.exports = { trueCasePath, trueCasePathSync }`)
  • If relying on (undocumented) glob options, those will no longer work
  • Drop support for Node <=6

Features

  • Async version of function
  • TypeScript definitions

Bug Fixes