find-down
v0.1.4
Published
Find a file by walking down parent directories.
Downloads
860
Maintainers
Readme
find-down
Find a file by walking down parent directories.
Why?
- Find files high up in the filesystem quickly.
- Good at finding things that are probably in
$HOME
. - Is to find-up what
indexOf
is tolastIndexOf
.
Install
npm install find-down --save
Usage
Get it into your program.
const findDown = require('find-down');
Find the topmost file with the given name.
findDown('unicorn.png').then((filepath) => {
console.log(filepath); // => '/Users/sholladay/unicorn.png'
});
API
findDown(filename, option)
Returns a Promise
for either the filepath or null
if it cannot be found.
findDown([filenameA, filenameB], option)
Returns a Promise
for either the first filepath found (by respecting the order) or null
if none could be found.
filename
Type: string
Filename of the file to find.
option
cwd
Type: string
Default: process.cwd()
Directory to end with.
Contributing
See our contributing guidelines for more details.
- Fork it.
- Make a feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request.
License
Go make something, dang it.