1.2.0 • Published 1 year ago
@contrast/find-package-json v1.2.0
@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 >=16.9.1 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-jsonUsage
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
options
Type: object
cwd(string) - Directory to start from. Default:process.cwd()stopAt(string) - Absolute path to stop at. Default:path.parse(cwd).root