https://github.com/jameslnewell/find-and-read-package-json
Find and read data from a package.json file.
https://github.com/jameslnewell/find-and-read-package-json
find-package json package-json read-package
Last synced: about 2 months ago
JSON representation
Find and read data from a package.json file.
- Host: GitHub
- URL: https://github.com/jameslnewell/find-and-read-package-json
- Owner: jameslnewell
- Created: 2016-07-12T05:46:29.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-06-19T14:13:19.000Z (almost 8 years ago)
- Last Synced: 2025-09-13T15:33:52.957Z (9 months ago)
- Topics: find-package, json, package-json, read-package
- Language: TypeScript
- Size: 41 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# find-and-read-package-json
Find and read data from a `package.json` file.
## Installation
```bash
npm install --save find-and-read-package-json
```
## Usage
```js
import findAndReadPackageJSON from 'find-and-read-package-json';
findAndReadPackageJSON(process.cwd())
.then(({file, json}) => console.log(file, json))
.catch(error => console.error(error))
;
```
## API
```js
findAndReadPackageJSON(directory: string, options: Options): Promise<{file: string; json: any}>
```
Find and read data from a `package.json` file that exists in the provided directory, or that exists in a parent
directory of the provided directory.
##### Parameters
- `directory`: `string` - Required. The directory we will start looking for a `package.json` file in.
- `options`
- `cache`: `{[file: string]: any}` - Optional. An object shared between calls to `findAndReadPackageJSON()` to reduce repeated
calls to
`fs
.readFile()`.
- `transform`: `(json : any) => any` Optional. A function to transform the JSON read from a `package.json` file (to save large chunks of JSON from being cached).