Skip to content
Find the first file matching a given pattern in the current directory or the nearest ancestor directory.
Branch: master
Clone or download
Latest commit 15a8d32 Dec 29, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Scaffold: Normalize repository Dec 28, 2018
.editorconfig Scaffold: Normalize repository Dec 28, 2018
.eslintrc Scaffold: Normalize repository Dec 28, 2018
.gitattributes Breaking: Massive refactor & now uses micromatch (closes #26, #25, #15, Dec 28, 2018
.gitignore Scaffold: Normalize repository Dec 28, 2018
.npmrc Scaffold: Normalize repository Dec 28, 2018
.travis.yml Scaffold: Normalize repository Dec 28, 2018
LICENSE Scaffold: Normalize repository Dec 28, 2018
README.md Scaffold: Normalize repository Dec 28, 2018
appveyor.yml Scaffold: Normalize repository Dec 28, 2018
index.js Scaffold: Normalize repository Dec 28, 2018
package.json

README.md

findup-sync

NPM version Downloads Travis Build Status AppVeyor Build Status Coveralls Status Gitter chat

Find the first file matching a given pattern in the current directory or the nearest ancestor directory.

Matching is done with micromatch, please report any matching related issues on that repository.

Usage

var findup = require('findup-sync');
findup(patternOrPatterns [, micromatchOptions]);

// Start looking in the CWD.
var filepath1 = findup('{a,b}*.txt');

// Start looking somewhere else, and ignore case (probably a good idea).
var filepath2 = findup('{a,b}*.txt', {cwd: '/some/path', nocase: true});

API

findup(patterns, [options])

  • patterns {String|Array}: Glob pattern(s) or file path(s) to match against.
  • options {Object}: Options to pass to micromatch. Note that if you want to start in a different directory than the current working directory, specify a cwd property here.
  • returns {String}: Returns the first matching file.

License

MIT

You can’t perform that action at this time.