@simbo/find-up-package
v1.0.3
Published
A utility for finding an npm package in the directory hierarchy that matches specific criteria.
Maintainers
Readme
Find Up Package
A utility for finding an npm package in the directory hierarchy that matches specific criteria.
It uses find-up to walk up the
filesystem, checking each package.json until it finds a match.
⸻
Features
Search upwards for a
package.jsonfile matching custom conditionsConfigurable matcher function for defining what counts as a match
Returns the found directory path and the parsed
package.jsonOptionally normalize the
package.jsonusing npm'snormalize-package-dataAsync, Promise-based API
Fully typed with TypeScript
Installation
Install @simbo/find-up-package from the npm registry:
npm i [-D] @simbo/find-up-packageUsage
For a complete API reference, see the documentation.
Example
import { findUpPackage } from '@simbo/find-up-package';
const result = await findUpPackage();
if (result) {
console.log(`Found package.json in: ${result.path}`);
console.log(result.packageJson.name, result.packageJson.version);
}