fs-find-root

2.0.0 • Public • Published

fs-find-root

Build Status npm install npm version js-standard-style License

search up directories until you find what you're looking for

usage

var find = require('fs-find-root')

  • find('dir', name, startingDirectory) searches for directory name starting from startDirectory and returns a promise.
  • find.dir(name, startingDirectory) is equivalent to the above.
  • find('file', name, startingDirectory) searches for file name starting from startDirectory and 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 null if the file or directory is not found.

license

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    1,319
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    1,319
  • 1.0.2
    17
  • 1.0.1
    1
  • 0.0.0
    1

Package Sidebar

Install

npm i fs-find-root

Weekly Downloads

1,338

Version

2.0.0

License

MIT

Last publish

Collaborators

  • jarofghosts