1 |
3a515b92
|
cagy
|
<p align="center">
|
2 |
|
|
<a href="http://gulpjs.com">
|
3 |
|
|
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
|
4 |
|
|
</a>
|
5 |
|
|
</p>
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
# findup-sync
|
9 |
|
|
|
10 |
|
|
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
|
11 |
|
|
|
12 |
|
|
Find the first file matching a given pattern in the current directory or the nearest ancestor directory.
|
13 |
|
|
|
14 |
|
|
Matching is done with [micromatch][micromatch], please report any matching related issues on that repository.
|
15 |
|
|
|
16 |
|
|
## Usage
|
17 |
|
|
|
18 |
|
|
```js
|
19 |
|
|
var findup = require('findup-sync');
|
20 |
|
|
findup(patternOrPatterns [, micromatchOptions]);
|
21 |
|
|
|
22 |
|
|
// Start looking in the CWD.
|
23 |
|
|
var filepath1 = findup('{a,b}*.txt');
|
24 |
|
|
|
25 |
|
|
// Start looking somewhere else, and ignore case (probably a good idea).
|
26 |
|
|
var filepath2 = findup('{a,b}*.txt', {cwd: '/some/path', nocase: true});
|
27 |
|
|
```
|
28 |
|
|
|
29 |
|
|
## API
|
30 |
|
|
|
31 |
|
|
### `findup(patterns, [options])`
|
32 |
|
|
|
33 |
|
|
* `patterns` **{String|Array}**: Glob pattern(s) or file path(s) to match against.
|
34 |
|
|
* `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.
|
35 |
|
|
* `returns` **{String}**: Returns the first matching file.
|
36 |
|
|
|
37 |
|
|
## License
|
38 |
|
|
|
39 |
|
|
MIT
|
40 |
|
|
|
41 |
|
|
[micromatch]: http://github.com/jonschlinkert/micromatch
|
42 |
|
|
|
43 |
|
|
[downloads-image]: http://img.shields.io/npm/dm/findup-sync.svg
|
44 |
|
|
[npm-url]: https://www.npmjs.com/package/findup-sync
|
45 |
|
|
[npm-image]: http://img.shields.io/npm/v/findup-sync.svg
|
46 |
|
|
|
47 |
|
|
[travis-url]: https://travis-ci.org/gulpjs/findup-sync
|
48 |
|
|
[travis-image]: http://img.shields.io/travis/gulpjs/findup-sync.svg?label=travis-ci
|
49 |
|
|
|
50 |
|
|
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/findup-sync
|
51 |
|
|
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/findup-sync.svg?label=appveyor
|
52 |
|
|
|
53 |
|
|
[coveralls-url]: https://coveralls.io/r/gulpjs/findup-sync
|
54 |
|
|
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/findup-sync/master.svg
|
55 |
|
|
|
56 |
|
|
[gitter-url]: https://gitter.im/gulpjs/gulp
|
57 |
|
|
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg
|