pkg-dir
Advanced tools
Comparing version 3.0.0 to 4.0.0
12
index.js
@@ -5,7 +5,13 @@ 'use strict'; | ||
module.exports = cwd => findUp('package.json', {cwd}).then(fp => fp ? path.dirname(fp) : null); | ||
const pkgDir = async cwd => { | ||
const filePath = await findUp('package.json', {cwd}); | ||
return filePath ? path.dirname(filePath) : undefined; | ||
}; | ||
module.exports = pkgDir; | ||
module.exports.default = pkgDir; | ||
module.exports.sync = cwd => { | ||
const fp = findUp.sync('package.json', {cwd}); | ||
return fp ? path.dirname(fp) : null; | ||
const filePath = findUp.sync('package.json', {cwd}); | ||
return filePath ? path.dirname(filePath) : undefined; | ||
}; |
{ | ||
"name": "pkg-dir", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Find the root directory of a Node.js project or npm package", | ||
@@ -13,9 +13,10 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
"test": "xo && ava && tsd-check" | ||
}, | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
@@ -51,5 +52,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
"ava": "^1.3.1", | ||
"tsd-check": "^0.3.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -43,7 +43,7 @@ # pkg-dir [![Build Status](https://travis-ci.org/sindresorhus/pkg-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-dir) | ||
Returns a `Promise` for either the project root path or `null` if it couldn't be found. | ||
Returns a `Promise` for either the project root path or `undefined` if it couldn't be found. | ||
### pkgDir.sync([cwd]) | ||
Returns the project root path or `null`. | ||
Returns the project root path or `undefined`. | ||
@@ -50,0 +50,0 @@ #### cwd |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
4221
5
30
0
3