File: index.d.ts

package info (click to toggle)
node-read-pkg-up 7.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 136 kB
  • sloc: javascript: 43; makefile: 2
file content (87 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (8)
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
78
79
80
81
82
83
84
85
86
87
import {Except} from 'type-fest';
import readPkg = require('read-pkg');

declare namespace readPkgUp {
	type Options = {
		/**
		Directory to start looking for a package.json file.

		@default process.cwd()
		*/
		cwd?: string;
	} & Except<readPkg.Options, 'cwd'>;

	type NormalizeOptions = {
		/**
		Directory to start looking for a package.json file.

		@default process.cwd()
		*/
		cwd?: string;
	} & Except<readPkg.NormalizeOptions, 'cwd'>;

	type PackageJson = readPkg.PackageJson;
	type NormalizedPackageJson = readPkg.NormalizedPackageJson;

	interface ReadResult {
		packageJson: PackageJson;
		path: string;
	}

	interface NormalizedReadResult {
		packageJson: NormalizedPackageJson;
		path: string;
	}
}

declare const readPkgUp: {
	/**
	Read the closest `package.json` file.

	@example
	```
	import readPkgUp = require('read-pkg-up');

	(async () => {
		console.log(await readPkgUp());
		// {
		// 	packageJson: {
		// 		name: 'awesome-package',
		// 		version: '1.0.0',
		// 		…
		// 	},
		// 	path: '/Users/sindresorhus/dev/awesome-package/package.json'
		// }
	})();
	```
	*/
	(options?: readPkgUp.NormalizeOptions): Promise<
		readPkgUp.NormalizedReadResult | undefined
	>;
	(options: readPkgUp.Options): Promise<readPkgUp.ReadResult | undefined>;

	/**
	Synchronously read the closest `package.json` file.

	@example
	```
	import readPkgUp = require('read-pkg-up');

	console.log(readPkgUp.sync());
	// {
	// 	packageJson: {
	// 		name: 'awesome-package',
	// 		version: '1.0.0',
	// 		…
	// 	},
	// 	path: '/Users/sindresorhus/dev/awesome-package/package.json'
	// }
	```
	*/
	sync(
		options?: readPkgUp.NormalizeOptions
	): readPkgUp.NormalizedReadResult | undefined;
	sync(options: readPkgUp.Options): readPkgUp.ReadResult | undefined;
};

export = readPkgUp;