.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / find-up / readme.md
1 # find-up [![Build Status: Linux and macOS](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/l0cyjmvh5lq72vq2/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/find-up/branch/master)
2
3 > Find a file by walking up parent directories
4
5
6 ## Install
7
8 ```
9 $ npm install --save find-up
10 ```
11
12
13 ## Usage
14
15 ```
16 /
17 └── Users
18                 └── sindresorhus
19                                 ├── unicorn.png
20                                 └── foo
21                                                 └── bar
22                                                                 ├── baz
23                                                                 └── example.js
24 ```
25
26 ```js
27 // example.js
28 const findUp = require('find-up');
29
30 findUp('unicorn.png').then(filepath => {
31         console.log(filepath);
32         //=> '/Users/sindresorhus/unicorn.png'
33 });
34
35 findUp(['rainbow.png', 'unicorn.png']).then(filepath => {
36         console.log(filepath);
37         //=> '/Users/sindresorhus/unicorn.png'
38 });
39 ```
40
41
42 ## API
43
44 ### findUp(filename, [options])
45
46 Returns a `Promise` for the filepath or `null`.
47
48 ### findUp([filenameA, filenameB], [options])
49
50 Returns a `Promise` for the first filepath found (by respecting the order) or `null`.
51
52 ### findUp.sync(filename, [options])
53
54 Returns a filepath or `null`.
55
56 ### findUp.sync([filenameA, filenameB], [options])
57
58 Returns the first filepath found (by respecting the order) or `null`.
59
60 #### filename
61
62 Type: `string`
63
64 Filename of the file to find.
65
66 #### options
67
68 ##### cwd
69
70 Type: `string`<br>
71 Default: `process.cwd()`
72
73 Directory to start from.
74
75
76 ## Related
77
78 - [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
79 - [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
80 - [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
81
82
83 ## License
84
85 MIT © [Sindre Sorhus](https://sindresorhus.com)