Find, read and parse the first matching file found walking the filesystem upwards.
npm install find-up-jsonFind, read and parse the first matching file found walking the filesystem upwards.
Compared to alternatives this library is _tiny_, it has no dependencies, and it can be bundled without problems.
``sh`
npm install find-up-json
`ts
import findUp from 'find-up-json';
// Let's find the nearest package.json file
const pkg = findUp ( 'package.json' );
// =>
// {
// path: '/path/to/found/package.json',
// buffer: BufferContentOfFile,
// content: {
// // Result of JSON-parsing the content of the file
// "name": "something..."
// // ...
// }
// }
``
MIT © Fabio Spampinato