Socket
Socket
Sign inDemoInstall

find-file

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-file - npm Package Compare versions

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)
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