find-nearest-package-json
v2.0.1
Published
Find the nearest package.json by recursively crawling parent directories
Downloads
5,900
Readme
find-nearest-package-json
Find the nearest package.json
by recursively crawling parent directories
Usage
Install find-nearest-package-json by running
yarn add find-nearest-package-json
import {
findNearestPackageJson,
findNearestPackageJsonSync
} from 'find-nearest-package-json'
async function runAsync() {
const packageJsonNearestCwd = await findNearestPackageJson()
const packageJsonNearestGivenDir = await findNearestPackageJson('/tmp/some-project/some-dir')
console.log(packageJsonNearestGivenDir.path)
console.log(packageJsonNearestGivenDir.data)
}
function runSync() {
const packageJsonNearestCwd = findNearestPackageJsonSync()
const packageJsonNearestGivenDir = findNearestPackageJsonSync('/tmp/some-project/some-dir')
console.log(packageJsonNearestGivenDir.path)
console.log(packageJsonNearestGivenDir.data)
}