forked from sindresorhus/read-package-up
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
77 lines (64 loc) · 1.75 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import {Except} from 'type-fest';
import {readPackageAsync, readPackageSync, Options as ReadPackageOptions, NormalizeOptions as ReadPackageNormalizeOptions, PackageJson, NormalizedPackageJson} from 'read-pkg';
export type Options = {
/**
Directory to start looking for a package.json file.
@default process.cwd()
*/
cwd?: string;
} & Except<ReadPackageOptions, 'cwd'>;
export type NormalizeOptions = {
/**
Directory to start looking for a package.json file.
@default process.cwd()
*/
cwd?: string;
} & Except<ReadPackageNormalizeOptions, 'cwd'>;
export interface ReadResult {
packageJson: PackageJson;
path: string;
}
export interface NormalizedReadResult {
packageJson: NormalizedPackageJson;
path: string;
}
export {
PackageJson,
NormalizedPackageJson
};
/**
Read the closest `package.json` file.
@example
```
import {readPackageUpAsync} from 'read-pkg-up';
console.log(await readPackageUpAsync());
// {
// packageJson: {
// name: 'awesome-package',
// version: '1.0.0',
// …
// },
// path: '/Users/sindresorhus/dev/awesome-package/package.json'
// }
```
*/
export function readPackageUpAsync(options?: NormalizeOptions): Promise<NormalizedReadResult | undefined>;
export function readPackageUpAsync(options: Options): Promise<ReadResult | undefined>;
/**
Synchronously read the closest `package.json` file.
@example
```
import {readPackageUpSync} from 'read-pkg-up';
console.log(readPackageUpSync());
// {
// packageJson: {
// name: 'awesome-package',
// version: '1.0.0',
// …
// },
// path: '/Users/sindresorhus/dev/awesome-package/package.json'
// }
```
*/
export function readPackageUpSync(options?: NormalizeOptions): NormalizedReadResult | undefined;
export function readPackageUpSync(options: Options): ReadResult | undefined;