https://github.com/gulpjs/findup-sync
Find the first file matching a given pattern in the current directory or the nearest ancestor directory.
https://github.com/gulpjs/findup-sync
findup glob micromatch resolve
Last synced: 5 months ago
JSON representation
Find the first file matching a given pattern in the current directory or the nearest ancestor directory.
- Host: GitHub
- URL: https://github.com/gulpjs/findup-sync
- Owner: gulpjs
- License: mit
- Created: 2012-11-01T21:52:53.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2023-12-29T20:10:49.000Z (almost 2 years ago)
- Last Synced: 2025-05-04T16:02:41.027Z (5 months ago)
- Topics: findup, glob, micromatch, resolve
- Language: JavaScript
- Size: 55.7 KB
- Stars: 98
- Watchers: 9
- Forks: 28
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# findup-sync
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
Find the first file matching a given pattern in the current directory or the nearest ancestor directory.
Matching is done with [micromatch][micromatch], please report any matching related issues on that repository.
## Usage
```js
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
[downloads-image]: https://img.shields.io/npm/dm/findup-sync.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/findup-sync
[npm-image]: https://img.shields.io/npm/v/findup-sync.svg?style=flat-square
[ci-url]: https://github.com/gulpjs/findup-sync/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/findup-sync/dev.yml?branch=master&style=flat-square
[coveralls-url]: https://coveralls.io/r/gulpjs/findup-sync
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/findup-sync/master.svg[micromatch]: http://github.com/micromatch/micromatch