1 | export type Options = {
|
2 | /**
|
3 | The directory to start searching from.
|
4 |
|
5 | @default process.cwd()
|
6 | */
|
7 | readonly cwd?: string;
|
8 | };
|
9 |
|
10 | /**
|
11 | Find the root directory of a Node.js project or npm package.
|
12 |
|
13 | @returns The project root path or `undefined` if it could not be found.
|
14 |
|
15 | @example
|
16 | ```
|
17 | // /
|
18 | // └── Users
|
19 | // └── sindresorhus
|
20 | // └── foo
|
21 | // ├── package.json
|
22 | // └── bar
|
23 | // ├── baz
|
24 | // └── example.js
|
25 |
|
26 | // example.js
|
27 | import {packageDirectory} from 'pkg-dir';
|
28 |
|
29 | console.log(await packageDirectory());
|
30 | //=> '/Users/sindresorhus/foo'
|
31 | ```
|
32 | */
|
33 | export function packageDirectory(options?: Options): Promise<string | undefined>;
|
34 |
|
35 | /**
|
36 | Synchronously find the root directory of a Node.js project or npm package.
|
37 |
|
38 | @returns The project root path or `undefined` if it could not be found.
|
39 |
|
40 | @example
|
41 | ```
|
42 | // /
|
43 | // └── Users
|
44 | // └── sindresorhus
|
45 | // └── foo
|
46 | // ├── package.json
|
47 | // └── bar
|
48 | // ├── baz
|
49 | // └── example.js
|
50 |
|
51 | // example.js
|
52 | import {packageDirectorySync} from 'pkg-dir';
|
53 |
|
54 | console.log(packageDirectorySync());
|
55 | //=> '/Users/sindresorhus/foo'
|
56 | ```
|
57 | */
|
58 | export function packageDirectorySync(options?: Options): string | undefined;
|