find-dir
v1.1.0
Published
find directory of file until root
Downloads
2
Readme
find-dir
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;