2.0.0 • Published 10 years ago
fs-find-root v2.0.0
fs-find-root
search up directories until you find what you're looking for
usage
var find = require('fs-find-root')
find('dir', name, startingDirectory)searches for directorynamestarting fromstartDirectoryand returns a promise.find.dir(name, startingDirectory)is equivalent to the above.find('file', name, startingDirectory)searches for filenamestarting fromstartDirectoryand returns a promise.find.file(name, startingDirectory)is equivalent to the above.
example
var find = require('fs-find-root')
// find a directory!
find.dir('.git', process.cwd())
.then(function (found) {
console.log('found the root of your git repo @ ' + found)
})
// find a file!
find.file('package.json', process.cwd())
.then(function (found) {
console.log('found yer package.json right here: ' + found)
})notes
- resolves with
nullif the file or directory is not found.
license
MIT