Acme.BookStore.HttpApi.Host/node_modules/detect-file/README.md
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
# detect-file [](https://www.npmjs.com/package/detect-file) [](https://npmjs.org/package/detect-file) [](https://npmjs.org/package/detect-file) [](https://travis-ci.org/doowb/detect-file) [](https://ci.appveyor.com/project/doowb/detect-file)
> Detects if a file exists and returns the resolved filepath.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save detect-file
```
Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add detect-file
```
## Usage
```js
var detect = require('detect-file');
```
## API
### [detect](index.js#L33)
Detect the given `filepath` if it exists.
**Params**
* `filepath` **{String}**: filepath to detect.
* `options` **{Object}**: Additional options.
* `options.nocase` **{Boolean}**: Set this to `true` to force case-insensitive filename checks. This is useful on case sensitive file systems.
* `returns` **{String}**: Returns the detected filepath if it exists, otherwise returns `null`.
**Example**
```js
var res = detect('package.json');
console.log(res);
//=> "package.json"
var res = detect('fake-file.json');
console.log(res)
//=> null
```
## Case sensitive file systems
When using the `nocase` option, this library will attempt to detect the filepath with the following methods:
1. Try to read all files in the `filepath` using `fs.readdirSync`. If successful and `filepath` is a directory, return the `filepath`.
2. Try to read all files in the `filepath`'s directory using `fs.readdirSync`. If successful, do case insensitive comparasions of the `filepath` to the files in `filepath`'s directory.
## About
### Related projects
后面还有 39 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
