closest-package
Find the closest package.json file meeting specific criteria
Last updated 10 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install closest-package 
SYNC missed versions from official npm registry.

closest-package experimental

Find the closest package.json file meeting specific criteria by searching upwards from a given directory until hitting root.

Usage

NPM

closest(dir, [filter], found(err, file))

Given a starting directory dir, look up through every directory to see if it contains a package.json file matching the filter function, for example:

closest(__dirname, function(json, filename) {
  return json.name === 'async'
}, function(err, file) {
  console.log(file)
})

Note that filter is optional and takes the following arguments:

  • json: the parsed package.json file.
  • filename: the package.json's absolute filename.

file = closest.sync(dir, [filter])

Same as the closest function, however executed synchronously:

var result = closest.sync(__dirname, function(json, filename) {
  return json.name === 'async'
})

console.log(result)

License

MIT. See LICENSE.md for details.

Current Tags

  • 1.0.0                                ...           latest (10 years ago)

1 Versions

  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 5
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE