lhl 8884f64fe1 10-8 | 3 年之前 | |
---|---|---|
.. | ||
index.js | 3 年之前 | |
license | 3 年之前 | |
package.json | 3 年之前 | |
readme.md | 3 年之前 |
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