Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detect-file

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-file - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

15

index.js
/*!
* detect-file (https://github.com/doowb/detect-file)
* detect-file <https://github.com/doowb/detect-file>
*
* Copyright (c) 2016, Brian Woodward.
* Licensed under the MIT License.
* Copyright (c) 2016-2017, Brian Woodward.
* Released under the MIT License.
*/

@@ -12,6 +12,5 @@

var path = require('path');
var exists = require('fs-exists-sync');
/**
* Resolve the given `filepath` if it exists.
* Detect the given `filepath` if it exists.
*

@@ -30,4 +29,4 @@ * ```js

* @param {Object} `options` Additional options.
* @param {Boolean} `options.nocase` Set this to `true` force case-insensitive filename checks. This is useful on case sensitive file systems.
* @return {String} Returns the resolved filepath if it exists, otherwise returns `null`.
* @param {Boolean} `options.nocase` Set this to `true` to force case-insensitive filename checks. This is useful on case sensitive file systems.
* @return {String} Returns the detected filepath if it exists, otherwise returns `null`.
* @api public

@@ -40,3 +39,3 @@ */

}
if (exists(filepath)) {
if (fs.existsSync(filepath)) {
return path.resolve(filepath);

@@ -43,0 +42,0 @@ }

{
"name": "detect-file",
"description": "Detect if a filepath exists and resolves the full filepath.",
"version": "0.1.0",
"description": "Detects if a file exists and returns the resolved filepath.",
"version": "1.0.0",
"homepage": "https://github.com/doowb/detect-file",

@@ -22,5 +22,3 @@ "author": "Brian Woodward (https://github.com/doowb)",

},
"dependencies": {
"fs-exists-sync": "^0.1.0"
},
"dependencies": {},
"devDependencies": {

@@ -30,5 +28,19 @@ "gulp-format-md": "*",

},
"keywords": [],
"keywords": [
"detect",
"exists",
"file",
"file exists",
"file-path",
"filepath",
"path",
"resolve",
"resolve file",
"resolve filepath"
],
"verb": {
"layout": "default",
"tasks": [
"readme"
],
"plugins": [

@@ -45,4 +57,7 @@ "gulp-format-md"

"verb-readme-generator"
]
],
"lint": {
"reflinks": true
}
}
}

@@ -1,4 +0,4 @@

# detect-file [![NPM version](https://img.shields.io/npm/v/detect-file.svg?style=flat)](https://www.npmjs.com/package/detect-file) [![NPM downloads](https://img.shields.io/npm/dm/detect-file.svg?style=flat)](https://npmjs.org/package/detect-file) [![Build Status](https://img.shields.io/travis/doowb/detect-file.svg?style=flat)](https://travis-ci.org/doowb/detect-file)
# detect-file [![NPM version](https://img.shields.io/npm/v/detect-file.svg?style=flat)](https://www.npmjs.com/package/detect-file) [![NPM monthly downloads](https://img.shields.io/npm/dm/detect-file.svg?style=flat)](https://npmjs.org/package/detect-file) [![NPM total downloads](https://img.shields.io/npm/dt/detect-file.svg?style=flat)](https://npmjs.org/package/detect-file) [![Linux Build Status](https://img.shields.io/travis/doowb/detect-file.svg?style=flat&label=Travis)](https://travis-ci.org/doowb/detect-file) [![Windows Build Status](https://img.shields.io/appveyor/ci/doowb/detect-file.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/doowb/detect-file)
Detect if a filepath exists and resolves the full filepath.
> Detects if a file exists and returns the resolved filepath.

@@ -13,2 +13,8 @@ ## Install

Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add detect-file
```
## Usage

@@ -22,5 +28,5 @@

### [detect](index.js#L34)
### [detect](index.js#L33)
Resolve the given `filepath` if it exists.
Detect the given `filepath` if it exists.

@@ -31,4 +37,4 @@ **Params**

* `options` **{Object}**: Additional options.
* `options.nocase` **{Boolean}**: Set this to `true` force case-insensitive filename checks. This is useful on case sensitive file systems.
* `returns` **{String}**: Returns the resolved filepath if it exists, otherwise returns `null`.
* `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`.

@@ -47,35 +53,38 @@ **Example**

## Related projects
## Case sensitive file systems
You might also be interested in these projects:
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
[fs-exists-sync](https://www.npmjs.com/package/fs-exists-sync): Drop-in replacement for `fs.existsSync` with zero dependencies. Other libs I found either have crucial differences… [more](https://github.com/jonschlinkert/fs-exists-sync) | [homepage](https://github.com/jonschlinkert/fs-exists-sync "Drop-in replacement for `fs.existsSync` with zero dependencies. Other libs I found either have crucial differences from fs.existsSync, or unnecessary dependencies. See README.md for more info.")
## Contributing
### Contributing
This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (a [verb](https://github.com/verbose/verb) generator), please don't edit directly. Any changes to the readme must be made in [.verb.md](.verb.md). See [Building Docs](#building-docs).
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Or visit the [verb-readme-generator](https://github.com/verbose/verb-readme-generator) project to submit bug reports or pull requests for the readme layout template.
### Building docs
## Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
_(This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
To generate the readme, run the following command:
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm install -g verb verb-readme-generator && verb
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
## Running tests
### Running tests
Install dev dependencies:
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install -d && npm test
$ npm install && npm test
```
## Author
### Author

@@ -85,11 +94,11 @@ **Brian Woodward**

* [github/doowb](https://github.com/doowb)
* [twitter/doowb](http://twitter.com/doowb)
* [twitter/doowb](https://twitter.com/doowb)
## License
### License
Copyright © 2016, [Brian Woodward](https://github.com/doowb).
Released under the [MIT license](https://github.com/doowb/detect-file/blob/master/LICENSE).
Copyright © 2017, [Brian Woodward](https://github.com/doowb).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 06, 2016._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 05, 2017._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc