Socket
Socket
Sign inDemoInstall

find-up-glob

Package Overview
Dependencies
12
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    find-up-glob

Find a file by walking up parent directories


Version published
Maintainers
1
Install size
142 kB
Created

Readme

Source

find-up-glob

travis status npm version npm download david dependency david dev-dependency

Find a file by walking up parent directories

Like find-up but using minimatch

Installation

$ npm install --save find-up-glob

Usage

/
└── Users
    └── tanhauhau
        ├── unicorn.png
        └── foo
            └── bar
                ├── a.js
                └── b.js
            └── awesome.txt
            └── super.txt
var findUpGlob = require('find-up-glob');

//asynchronous using promise
findUpGlob('*.js').then(function(files){
    console.log(files)
    //=> ['/Users/tanhauhau/foo/bar/a.js', '/Users/tanhauhau/foo/bar/b.js']
})

//synchronous
var files = findUpGlob.sync('*.txt');
//=> ['/Users/tanhauhau/foo/awesome.txt', '/Users/tanhauhau/foo/super.txt']

API

findUpGlob(glob, [options])

Returns a promise for the array of filepath or null.

findUpGlob.sync(glob, [options])

Returns an array of filepath or null.

glob
Type: string
Glob pattern for filename matching, using minimatch to match

options
cwd
Type: string
Default: process.cwd()
Directory to start from.

Caveat

To match a parent folder you should use:
findUpGlob('**/bar/*.js') instead of findUpGlob('/bar/*.js')

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

Keywords

FAQs

Last updated on 06 May 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc