1.1.0 • Published 8 years ago

find-dir v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

find-dir

Build ld Status Test Coverage

Find directory of file until root

usage

Here is the usage with asynchronous operation.

const findDir = require('find-dir');

findDir((err, res) => {
  console.log(res); // the dir where 'package.json' resides
});

findDir('file', (err, res) => {
  console.log(res); // the dir where 'file' resides
});

findDir({ target: 'file' }, (err, res) => {
  console.log(res); // the dir where 'file' resides
});

findDir({ dir: __dirname, target: 'file' }, (err, res) => {
  console.log(res); // the dir where 'file' resides
                    // but start searching from 'dir' (default is process.cwd())
});

The same can be achieved with synchronous operation from:

const findDir = require('find-dir').findDirSync;