Skip to content

Commit 876de53

Browse files
committed
Add more precise types for the package-up utility
1 parent 193d10e commit 876de53

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/utils/package-up.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ const { fileURLToPath } = require('url');
1616
/**
1717
* Inlined version of the package "package-up" (ESM only).
1818
*
19-
* @param {string} cwd The directory to start searching from.
19+
* @param {object} options
20+
* @param {string} options.cwd The directory to start searching from.
2021
* @returns {string|undefined} The path to the nearest package.json file or undefined if not found.
2122
*/
2223
module.exports = function({ cwd }) {
2324
return findUpSync('package.json', { cwd, type: 'file' });
2425
};
2526

27+
/**
28+
* @param {string|URL} urlOrPath
29+
* @returns {string}
30+
*/
2631
function toPath(urlOrPath) {
2732
return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
2833
}
@@ -32,7 +37,7 @@ function toPath(urlOrPath) {
3237
*
3338
* @param {string} name The name of the file to find
3439
* @param {object} options
35-
* @param {string} options.cwd The directory to start searching from.
40+
* @param {string=} options.cwd The directory to start searching from.
3641
* @returns {string|undefined} The path to the file found or undefined if not found.
3742
*/
3843
function findUpSync(name, { cwd = process.cwd() } = {}) {

0 commit comments

Comments
 (0)