/
index.d.ts
59 lines (45 loc) · 1.37 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
import * as typeFest from 'type-fest';
import * as normalize from 'normalize-package-data';
export interface Options {
/**
Current working directory.
@default process.cwd()
*/
readonly cwd?: string;
/**
[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
@default true
*/
readonly normalize?: boolean;
}
export interface NormalizeOptions extends Options {
readonly normalize?: true;
}
export type NormalizedPackageJson = PackageJson & normalize.Package;
export type PackageJson = typeFest.PackageJson;
/**
@returns The parsed JSON.
@example
```
import {readPackageAsync} from 'read-pkg';
console.log(await readPackageAsync());
//=> {name: 'read-pkg', …}
console.log(await readPackageAsync({cwd: 'some-other-directory'});
//=> {name: 'unicorn', …}
```
*/
export function readPackageAsync(options?: NormalizeOptions): Promise<NormalizedPackageJson>;
export function readPackageAsync(options: Options): Promise<PackageJson>;
/**
@returns The parsed JSON.
@example
```
import {readPackageSync} from 'read-pkg';
console.log(readPackageSync());
//=> {name: 'read-pkg', …}
console.log(readPackageSync({cwd: 'some-other-directory'});
//=> {name: 'unicorn', …}
```
*/
export function readPackageSync(options?: NormalizeOptions): NormalizedPackageJson;
export function readPackageSync(options: Options): PackageJson;