|
|
%!s(int64=2) %!d(string=hai) anos | |
|---|---|---|
| .. | ||
| index.js | %!s(int64=2) %!d(string=hai) anos | |
| license | %!s(int64=2) %!d(string=hai) anos | |
| package.json | %!s(int64=2) %!d(string=hai) anos | |
| readme.md | %!s(int64=2) %!d(string=hai) anos | |
Find a file or directory by walking up parent directories
$ npm install find-up
/
└── Users
└── sindresorhus
├── unicorn.png
└── foo
└── bar
├── baz
└── example.js
example.js
const findUp = require('find-up');
(async () => {
console.log(await findUp('unicorn.png'));
//=> '/Users/sindresorhus/unicorn.png'
console.log(await findUp(['rainbow.png', 'unicorn.png']));
//=> '/Users/sindresorhus/unicorn.png'
})();
Returns a Promise for either the filepath or null if it couldn't be found.
Returns a Promise for either the first filepath found (by respecting the order) or null if none could be found.
Returns a filepath or null.
Returns the first filepath found (by respecting the order) or null.
Type: string
Filename of the file to find.
Type: Object
Type: string
Default: process.cwd()
Directory to start from.
require.resolve() but from a given pathMIT © Sindre Sorhus