Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

find-up-glob

1.0.0 • Public • Published

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

Install

npm i find-up-glob

DownloadsWeekly Downloads

5

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar