pkg-dir
Advanced tools
Comparing version 4.0.0 to 4.1.0
declare const pkgDir: { | ||
/** | ||
* Find the root directory of a Node.js project or npm package. | ||
* | ||
* @param cwd - Directory to start from. Default: `process.cwd()`. | ||
* @returns A `Promise` for either the project root path or `undefined` if it couldn't be found. | ||
*/ | ||
Find the root directory of a Node.js project or npm package. | ||
@param cwd - Directory to start from. Default: `process.cwd()`. | ||
@returns The project root path or `undefined` if it couldn't be found. | ||
@example | ||
``` | ||
// / | ||
// └── Users | ||
// └── sindresorhus | ||
// └── foo | ||
// ├── package.json | ||
// └── bar | ||
// ├── baz | ||
// └── example.js | ||
// example.js | ||
import pkgDir = require('pkg-dir'); | ||
(async () => { | ||
const rootDir = await pkgDir(__dirname); | ||
console.log(rootDir); | ||
//=> '/Users/sindresorhus/foo' | ||
})(); | ||
``` | ||
*/ | ||
(cwd?: string): Promise<string | undefined>; | ||
/** | ||
* Synchronously find the root directory of a Node.js project or npm package. | ||
* | ||
* @param cwd - Directory to start from. Default: `process.cwd()`. | ||
* @returns The project root path or `undefined`. | ||
*/ | ||
Synchronously find the root directory of a Node.js project or npm package. | ||
@param cwd - Directory to start from. Default: `process.cwd()`. | ||
@returns The project root path or `undefined` if it couldn't be found. | ||
*/ | ||
sync(cwd?: string): string | undefined; | ||
// TODO: Remove this for the next major release | ||
default: typeof pkgDir; | ||
}; | ||
export default pkgDir; | ||
export = pkgDir; |
@@ -11,2 +11,3 @@ 'use strict'; | ||
module.exports = pkgDir; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = pkgDir; | ||
@@ -13,0 +14,0 @@ |
{ | ||
"name": "pkg-dir", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Find the root directory of a Node.js project or npm package", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
"test": "xo && ava && tsd" | ||
}, | ||
@@ -52,6 +52,6 @@ "files": [ | ||
"devDependencies": { | ||
"ava": "^1.3.1", | ||
"tsd-check": "^0.3.0", | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -47,3 +47,3 @@ # pkg-dir [![Build Status](https://travis-ci.org/sindresorhus/pkg-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-dir) | ||
Returns the project root path or `undefined`. | ||
Returns the project root path or `undefined` if it couldn't be found. | ||
@@ -50,0 +50,0 @@ #### cwd |
4751
49