source: trip-planner-front/node_modules/pkg-dir/readme.md@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
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 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
28const pkgDir = require('pkg-dir');
29
30(async () => {
31 const rootDir = await pkgDir(__dirname);
32
33 console.log(rootDir);
34 //=> '/Users/sindresorhus/foo'
35})();
36```
37
38
39## API
40
41### pkgDir([cwd])
42
43Returns a `Promise` for either the project root path or `undefined` if it couldn't be found.
44
45### pkgDir.sync([cwd])
46
47Returns the project root path or `undefined` if it couldn't be found.
48
49#### cwd
50
51Type: `string`<br>
52Default: `process.cwd()`
53
54Directory to start from.
55
56
57## Related
58
59- [pkg-dir-cli](https://github.com/sindresorhus/pkg-dir-cli) - CLI for this module
60- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
61- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
62
63
64## License
65
66MIT © [Sindre Sorhus](https://sindresorhus.com)
Note: See TracBrowser for help on using the repository browser.