https://github.com/contrast-security-oss/find-package-json
Look up through directories to find package.json
https://github.com/contrast-security-oss/find-package-json
Last synced: about 1 month ago
JSON representation
Look up through directories to find package.json
- Host: GitHub
- URL: https://github.com/contrast-security-oss/find-package-json
- Owner: Contrast-Security-OSS
- Created: 2024-02-08T17:37:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-19T20:26:43.000Z (over 1 year ago)
- Last Synced: 2025-03-13T05:14:36.836Z (over 1 year ago)
- Language: JavaScript
- Size: 68.4 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @contrast/find-package-json
This is derived from Sindre Sorhus' `find-up-simple` [package](https://www.npmjs.com/package/find-up-simple).
It has been modified so that it is CJS, lowers `engine` to `>=16.9.1` in
`package.json`, and only looks for `package.json` files.
Starting in the current directory (by default) and continuing up the parent
directory chain, find `package.json` and return the absolute path or undefined.
## Install
```sh
$ npm install @contrast/find-package-json
```
## Usage
```js
const { findPackageJsonAsync, findPackageJsonSync } = require('@contrast/find-package-json');
(async () => {
console.log(await findPackageJsonAsync());
//=> '/Users/contrast/find-package-json/package.json'
})();
console.log(findPackageJsonSync());
//=> '/Users/contrast/find-package-json/package.json'
```
## API
- findPackageJsonAsync([options])
- findPackageJsonSync([options])
### options
Type: `object`
- `cwd` (string) - Directory to start from. Default: `process.cwd()`
- `stopAt` (string) - Absolute path to stop at. Default: `path.parse(cwd).root`