.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / pkg-dir / readme.md
1 # pkg-dir [![Build Status](https://travis-ci.org/sindresorhus/pkg-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-dir)
2
3 > Find the root directory of a Node.js project or npm package
4
5
6 ## Install
7
8 ```
9 $ npm install --save pkg-dir
10 ```
11
12
13 ## Usage
14
15 ```
16 /
17 └── Users
18     └── sindresorhus
19         └── foo
20             ├── package.json
21             └── bar
22                 ├── baz
23                 └── example.js
24 ```
25
26 ```js
27 // example.js
28 const pkgDir = require('pkg-dir');
29
30 pkgDir(__dirname).then(rootDir => {
31         console.log(rootDir);
32         //=> '/Users/sindresorhus/foo'
33 });
34 ```
35
36
37 ## API
38
39 ### pkgDir([cwd])
40
41 Returns a `Promise` for either the project root path or `null` if it couldn't be found.
42
43 ### pkgDir.sync([cwd])
44
45 Returns the project root path or `null`.
46
47 #### cwd
48
49 Type: `string`<br>
50 Default: `process.cwd()`
51
52 Directory to start from.
53
54
55 ## Related
56
57 - [pkg-dir-cli](https://github.com/sindresorhus/pkg-dir-cli) - CLI for this module
58 - [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
59 - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
60
61
62 ## License
63
64 MIT © [Sindre Sorhus](https://sindresorhus.com)