2.0.1 • Published 7 years ago

find-nearest-package-json v2.0.1

Weekly downloads
345
License
MIT
Repository
github
Last release
7 years ago

find-nearest-package-json

Build Status

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)
}