Skip to content

Commit d0b169e

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

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/utils/package-up.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ 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 {{cwd: string}} options The directory to start searching from.
2020
* @returns {string|undefined} The path to the nearest package.json file or undefined if not found.
2121
*/
2222
module.exports = function({ cwd }) {
2323
return findUpSync('package.json', { cwd, type: 'file' });
2424
};
2525

26+
/**
27+
* @param {string|URL} urlOrPath
28+
* @returns {string}
29+
*/
2630
function toPath(urlOrPath) {
2731
return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
2832
}
@@ -32,7 +36,7 @@ function toPath(urlOrPath) {
3236
*
3337
* @param {string} name The name of the file to find
3438
* @param {object} options
35-
* @param {string} options.cwd The directory to start searching from.
39+
* @param {string=} options.cwd The directory to start searching from.
3640
* @returns {string|undefined} The path to the file found or undefined if not found.
3741
*/
3842
function findUpSync(name, { cwd = process.cwd() } = {}) {

0 commit comments

Comments
 (0)