@@ -29,49 +29,49 @@ export interface PackageJson {
29
29
* Searches for the nearest `package.json` file, starting from the directory of
30
30
* the provided file path or url string and moving up the directory tree.
31
31
*
32
- * @param filePathOrUrl The file path or url string from which to start the
33
- * search. The url must be a file url. This is useful when you want to find
34
- * the nearest `package.json` file relative to the current module, as you
35
- * can use `import.meta.url`.
32
+ * @param pathOrUrl A path or url string from which to start the search. The url
33
+ * must be a file url. This is useful when you want to find the nearest
34
+ * `package.json` file relative to the current module, as you can use
35
+ * `import.meta.url`.
36
36
* @returns The absolute path to the nearest `package.json` file.
37
37
* @throws PackageJsonNotFoundError If no `package.json` file is found.
38
38
*/
39
39
export async function findClosestPackageJson (
40
- filePathOrUrl : string ,
40
+ pathOrUrl : string ,
41
41
) : Promise < string > {
42
- const filePath = getFilePath ( filePathOrUrl ) ;
42
+ const filePath = getFilePath ( pathOrUrl ) ;
43
43
44
44
if ( filePath === undefined ) {
45
- throw new PackageJsonNotFoundError ( filePathOrUrl ) ;
45
+ throw new PackageJsonNotFoundError ( pathOrUrl ) ;
46
46
}
47
47
48
- const packageJsonPath = await findUp ( "package.json" , path . dirname ( filePath ) ) ;
48
+ const packageJsonPath = await findUp ( "package.json" , filePath ) ;
49
49
50
50
if ( packageJsonPath === undefined ) {
51
- throw new PackageJsonNotFoundError ( filePathOrUrl ) ;
51
+ throw new PackageJsonNotFoundError ( pathOrUrl ) ;
52
52
}
53
53
54
54
return packageJsonPath ;
55
55
}
56
56
57
57
/**
58
- * Reads the nearest `package.json` file, starting from the directory of the
59
- * provided file path or url string and moving up the directory tree.
58
+ * Reads the nearest `package.json` file, starting from provided path or url
59
+ * string and moving up the directory tree.
60
60
*
61
- * @param filePathOrUrl The file path or url string from which to start the
62
- * search. The url must be a file url. This is useful when you want to find
63
- * the nearest `package.json` file relative to the current module, as you
64
- * can use `import.meta.url`.
61
+ * @param pathOrUrl A path or url string from which to start the search. The url
62
+ * must be a file url. This is useful when you want to find the nearest
63
+ * `package.json` file relative to the current module, as you can use
64
+ * `import.meta.url`.
65
65
* @returns The contents of the nearest `package.json` file, parsed as a
66
66
* {@link PackageJson} object.
67
67
* @throws PackageJsonNotFoundError If no `package.json` file is found.
68
68
* @throws PackageJsonReadError If the `package.json` file is found but cannot
69
69
* be read.
70
70
*/
71
71
export async function readClosestPackageJson (
72
- filePathOrUrl : string ,
72
+ pathOrUrl : string ,
73
73
) : Promise < PackageJson > {
74
- const packageJsonPath = await findClosestPackageJson ( filePathOrUrl ) ;
74
+ const packageJsonPath = await findClosestPackageJson ( pathOrUrl ) ;
75
75
try {
76
76
return await readJsonFile < PackageJson > ( packageJsonPath ) ;
77
77
} catch ( e ) {
@@ -81,16 +81,16 @@ export async function readClosestPackageJson(
81
81
}
82
82
83
83
/**
84
- * Finds the root directory of the nearest package, starting from the directory
85
- * of the provided file path or url string and moving up the directory tree.
84
+ * Finds the root directory of the nearest package, starting from the provided
85
+ * path or url string and moving up the directory tree.
86
86
*
87
87
* This function uses `findClosestPackageJson` to find the nearest `package.json`
88
88
* file and then returns the directory that contains that file.
89
89
*
90
- * @param filePathOrUrl The file path or url string from which to start the
91
- * search. The url must be a file url. This is useful when you want to find
92
- * the nearest `package.json` file relative to the current module, as you
93
- * can use `import.meta.url`.
90
+ * @param pathOrUrl A path or url string from which to start the search. The url
91
+ * must be a file url. This is useful when you want to find the nearest
92
+ * `package.json` file relative to the current module, as you can use
93
+ * `import.meta.url`.
94
94
* @returns The absolute path of the root directory of the nearest package.
95
95
*/
96
96
export async function findClosestPackageRoot (
0 commit comments