-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathindex.d.ts
68 lines (51 loc) · 1.83 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
import type {PackageJson as typeFestPackageJson} from 'type-fest';
import type {Package as normalizePackage} from 'normalize-package-data';
export type Options = {
/**
Current working directory.
@default process.cwd()
*/
readonly cwd?: URL | string;
/**
[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
@default true
*/
readonly normalize?: boolean;
};
// eslint-disable-next-line @typescript-eslint/naming-convention
type _NormalizeOptions = {
readonly normalize?: true;
};
export type NormalizeOptions = _NormalizeOptions & Options;
export type ParseOptions = Omit<Options, 'cwd'>;
export type NormalizeParseOptions = _NormalizeOptions & ParseOptions;
export type NormalizedPackageJson = PackageJson & normalizePackage;
export type PackageJson = typeFestPackageJson;
/**
@returns The parsed JSON.
@example
```
import {readPackage} from 'read-pkg';
console.log(await readPackage());
//=> {name: 'read-pkg', …}
console.log(await readPackage({cwd: 'some-other-directory'});
//=> {name: 'unicorn', …}
```
*/
export function readPackage(options?: NormalizeOptions): Promise<NormalizedPackageJson>;
export function readPackage(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;
export function parsePackage(packageFile: PackageJson | string, options?: NormalizeParseOptions): NormalizedPackageJson;
export function parsePackage(packageFile: PackageJson | string, options: ParseOptions): PackageJson;