Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 1.38 KB

.verb.md

File metadata and controls

64 lines (48 loc) · 1.38 KB

Usage

const find = require('{%= name %}');

async

find(filename, cwd, limit, callback);

Example

  • filename String - (required) the name of the file to find.
  • cwd String - (optional) the starting directory. This value can be prefixed with ~ to search from the user home directory.
  • limit Number - (optional) limit the number of directories to recurse.
  • callback Functional - (optional) A promise is returned when no callback is passed.

Promise example

// use "~" to search user home
find('foo.txt', '~/a/b/c')
  .then(file => console.log(file)) //=> '/Users/jonschlinkert/foo.txt'
  .catch(console.error);

With async-await

(async function() {
  const file = await find('foo.txt', '~/a/b/c');
  console.log(file);
  //=> '/Users/jonschlinkert/foo.txt'
})();

Callback example

// find `foo.txt` starting at the given directory
find('foo.txt', 'a/b/c', function(err, file) {
  if (err) throw err;
  console.log(file);
  //=> /Users/jonschlinkert/dev/find-file-up/fixtures/foo.txt
});

sync

find.sync(filename, cwd, limit);

Example

  • filename String - (required) the name of the file to find.
  • cwd String - (optional) the starting directory.
  • limit Number - (optional) limit the number of directories to recurse.
const file = find.sync('foo.txt', 'a/b/c/');