2.0.2 • Published 7 years ago
find-and-read-package-json v2.0.2
find-and-read-package-json
Find and read data from a package.json file.
Installation
npm install --save find-and-read-package-jsonUsage
import findAndReadPackageJSON from 'find-and-read-package-json';
findAndReadPackageJSON(process.cwd())
.then(({file, json}) => console.log(file, json))
.catch(error => console.error(error))
;API
findAndReadPackageJSON(directory: string, options: Options): Promise<{file: string; json: any}>Find and read data from a package.json file that exists in the provided directory, or that exists in a parent
directory of the provided directory.
Parameters
directory:string- Required. The directory we will start looking for apackage.jsonfile in.optionscache:{[file: string]: any}- Optional. An object shared between calls tofindAndReadPackageJSON()to reduce repeated calls tofs .readFile().transform:(json : any) => anyOptional. A function to transform the JSON read from apackage.jsonfile (to save large chunks of JSON from being cached).