Skip to content

mattdesl/read-closest-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

read-closest-package

stable

Reads the closest package.json file and parses its JSON.

require('read-closest-package')(function(err, data, filename) {
  console.log(data.version)
  console.log(data.description)
  console.log(filename)
})

Also has a sync API which returns null on any errors:

var closest = require('read-closest-package')

var pkg = closest.sync()
if (pkg) 
  console.log(pkg.version)

Usage

NPM

closest([opt], cb)

Looks for the closest package and calls the callback cb with (err, data, filename).

  • cwd the working directory to search up from for the package.json (defaults to process.cwd())
  • filter a filter passed to closest-package

If there was an error finding the pacakge or parsing JSON, err will be non-null.

data = closest.sync([opt])

The same as above, but synchronous. Returns null on any errors.

See Also

License

MIT, see LICENSE.md for details.

About

reads the closest package.json file

Resources

License

Stars

Watchers

Forks

Packages

No packages published