Comparing version 0.1.2 to 0.1.3
15
index.js
@@ -7,8 +7,12 @@ 'use strict'; | ||
/** | ||
* Search for a file in an array of paths dirs, excludes, global | ||
* Search for a file in an array of paths | ||
* | ||
* Options: | ||
* | ||
* - `path` Paths to search in | ||
* - `exclude` Paths to exclude | ||
* - `global` Whether to search in `PATH` | ||
* | ||
* @param {String} name | ||
* @param {String|Array} dirs | ||
* @param {String|Array} excludes | ||
* @param {Boolean} global | ||
* @param {Object} opts | ||
* @api public | ||
@@ -20,2 +24,3 @@ */ | ||
opts = opts || {}; | ||
opts.path = Array.isArray(opts.path) ? opts.path : [opts.path]; | ||
@@ -30,3 +35,3 @@ opts.exclude = Array.isArray(opts.exclude) ? opts.exclude : [opts.exclude]; | ||
file = opts.path.map(function (dir) { | ||
if (dir && opts.exclude.indexOf(dir) === -1) { | ||
if (dir && dir.indexOf(opts.exclude) === -1) { | ||
return path.join(dir, name); | ||
@@ -33,0 +38,0 @@ } |
{ | ||
"name": "find-file", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Search for a file in an array of paths", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -15,9 +15,9 @@ # find-file [![Build Status](https://travis-ci.org/kevva/find-file.png?branch=master)](http://travis-ci.org/kevva/find-file) | ||
// search for gifsicle in `vendor` and `../bin` | ||
findFile('gifsicle', ['vendor', '../bin']); | ||
findFile('gifsicle', { path: ['vendor', '../bin'] }); | ||
// search for gifsicle in `vendor` and `../bin` but exclude `PATH` | ||
findFile('gifsicle', ['vendor', '../bin'], false); | ||
findFile('gifsicle', { path: ['vendor', '../bin'], global: false }); | ||
// search for gifsicle in `vendor` and `PATH` but only return the first one | ||
findFile('gifsicle', 'vendor')[0]; | ||
findFile('gifsicle', { path: 'vendor' })[0]; | ||
``` | ||
@@ -27,9 +27,32 @@ | ||
### findFile(name, dirs, excludes, global) | ||
### findFile(name, opts) | ||
Search for a file in an array of paths. By default it will also search for | ||
Search for a file in an array of paths. By default it will also search for | ||
files in `PATH`. | ||
## Options | ||
### path | ||
Type: `String|Array` | ||
Default: `undefined` | ||
Paths to search in. | ||
### exclude | ||
Type: `String|Array` | ||
Default: `undefined` | ||
Paths to exclude. | ||
### global | ||
Type: `Boolean` | ||
Default: `true` | ||
Whether to search in `PATH`. | ||
## License | ||
[MIT License](http://en.wikipedia.org/wiki/MIT_License) (c) [Kevin Mårtensson](https://github.com/kevva) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2793
35
57