1.2.0 • Published 9 years ago

read-closest-package v1.2.0

Weekly downloads
513
License
MIT
Repository
github
Last release
9 years ago

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.