Skip to content

jameslnewell/find-and-read-package-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

find-and-read-package-json

Find and read data from a package.json file.

Installation

npm install --save find-and-read-package-json

Usage

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 a package.json file in.
  • options
    • cache: {[file: string]: any} - Optional. An object shared between calls to findAndReadPackageJSON() to reduce repeated calls to fs .readFile().
    • transform: (json : any) => any Optional. A function to transform the JSON read from a package.json file (to save large chunks of JSON from being cached).

About

Find and read data from a package.json file.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published