Project: vfile/vfile-find-up

Package: vfile-find-up@6.0.0

  1. Dependents: 11
  2. vfile utility to find one or more files by searching the file system upwards
  1. util 143
  2. utility 139
  3. file 34
  4. virtual 19
  5. vfile 17
  6. vfile-util 15
  7. find 10
  8. walk 8


Build Coverage Downloads Sponsors Backers Chat

Find vfiles by searching the file system upwards.


This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.


npm install vfile-find-up


import {findUp} from 'vfile-find-up'

findUp('package.json', console.log)


null [ VFile {
  data: {},
  messages: [],
  history: [ '/Users/tilde/projects/oss/vfile-find-up/package.json' ],
  cwd: '/Users/tilde/projects/oss/vfile-find-up' } ]


This package exports the following identifiers: findUp, findUpOne, INCLUDE, BREAK. There is no default export.

findUp(tests[, path][, callback])

Search for tests upwards. Calls callback with either an error or an array of files passing tests. Note: Virtual Files are not read (their contents is not populated).


Things to search for (string, Function, or Array.<tests>).

If a string is passed in, the basename or extname of files must match it for them to be included.

If an array is passed in, any test must match a given file for it to be included.

Otherwise, they must be function.


Place to searching from (string, default: process.cwd()).


Function called with all matching files (function cb(err[, files])).

findUpOne(tests[, path][, callback])

Like findUp, but either calls callback with the first found file, or null or without callback resolves to a file or null.

function test(file)

Check whether a virtual file should be included. Called with a vfile.


The different flags can be combined by using the pipe operator: INCLUDE | BREAK.


See contributing.md in vfile/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormer