search up directories until you find what you're looking for
var find = require('fs-find-root')
find('dir', name, startingDirectory, callback)
searches for directoryname
starting fromstartDirectory
and callscallback
with the results.find.dir(name, startingDirectory, callback)
is equivalent to the above.find('file', name, startingDirectory, callback)
searches for filename
starting fromstartDirectory
and callscallback
with the results.find.file(name, startingDirectory, callback)
is equivalent to the above.
var find = require('fs-find-root')
// find a directory!
find.dir('.git', process.cwd(), function(err, found) {
if(err) return err
console.log('found the root of your git repo @ ' + found)
})
// find a file!
find.file('package.json', process.cwd(), function(err, found) {
if(err) return err
console.log('found yer package.json right here: ' + found)
})
MIT