find-dir

1.1.0 • Public • Published

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;

Readme

Keywords

Package Sidebar

Install

npm i find-dir

Weekly Downloads

2

Version

1.1.0

License

MIT

Last publish

Collaborators

  • arch-mage