the-forest/client/node_modules/pkg-up
2024-09-17 20:35:18 -04:00
..
node_modules client raw doggin the db 2024-09-17 20:35:18 -04:00
index.d.ts client raw doggin the db 2024-09-17 20:35:18 -04:00
index.js client raw doggin the db 2024-09-17 20:35:18 -04:00
license client raw doggin the db 2024-09-17 20:35:18 -04:00
package.json client raw doggin the db 2024-09-17 20:35:18 -04:00
readme.md client raw doggin the db 2024-09-17 20:35:18 -04:00

pkg-up Build Status

Find the closest package.json file

Install

$ npm install pkg-up

Usage

/
└── Users
    └── sindresorhus
        └── foo
            ├── package.json
            └── bar
                ├── baz
                └── example.js
// example.js
const pkgUp = require('pkg-up');

(async () => {
	console.log(await pkgUp());
	//=> '/Users/sindresorhus/foo/package.json'
})();

API

pkgUp([options])

Returns a Promise<string> for the filepath, or Promise<null> if it couldn't be found.

pkgUp.sync([options])

Returns the filepath, or null if it couldn't be found.

options

Type: Object

cwd

Type: string
Default: process.cwd()

Directory to start from.

  • read-pkg-up - Read the closest package.json file
  • pkg-dir - Find the root directory of an npm package
  • find-up - Find a file by walking up parent directories

License

MIT © Sindre Sorhus