@contrast/find-package-json
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@contrast/find-package-json

This is derived from Sindre Sorhus' find-up-simple package. It has been modified so that it is CJS, lowers engine to >=14.21.3 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

$ npm install @contrast/find-package-json

Usage

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

Package Sidebar

Install

npm i @contrast/find-package-json

Weekly Downloads

21,928

Version

1.1.0

License

MIT

Unpacked Size

5.41 kB

Total Files

4

Last publish

Collaborators

  • planetlevel
  • contrastsec
  • tough-griff
  • annettenugent
  • michaelwitz
  • chrisdunne
  • contrast_admin
  • jcolekaplan
  • bmacnaughton