read-closest-package

reads the closest package.json file

MIT 5 个版本
安装
npm install read-closest-package
yarn add read-closest-package
pnpm add read-closest-package
bun add read-closest-package
README

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.

版本列表
1.2.0 2015-09-13
1.1.1 2015-09-02
1.1.0 2015-09-02
1.0.1 2015-04-30
1.0.0 2015-04-30