vfile-find-down
vfile utility to find one or more files by searching the file system downwards
Last updated 5 years ago by wooorm .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vfile-find-down 
SYNC missed versions from official npm registry.

vfile-find-down

Build Coverage Downloads Sponsors Backers Chat

Find vfiles by searching the file system downwards.

Install

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

npm:

npm install vfile-find-down

Use

var findDown = require('vfile-find-down')

findDown('.md', console.log)

Yields:

null [ VFile {
  data: {},
  messages: [],
  history: [ '/Users/tilde/projects/oss/vfile-find-down/readme.md' ],
  cwd: '/Users/tilde/projects/oss/vfile-find-down' } ]

API

This package exports the following identifiers: findDown, findDownOne, INCLUDE, SKIP, BREAK. There is no default export.

findDown(tests[, paths][, callback])

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

Signatures
  • (tests: Tests, paths?: string|Array.<string>, callback: Callback): void
  • (tests: Tests, paths?: string|Array.<string>): Promise.<Array.<VFile>>
Parameters
tests

Things to search for (string|Function|Array.<Tests>).

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

If a string is passed in, the basename or extname of files must match it for them to be included (and hidden directories and node_modules will not be searched).

Otherwise, they must be function.

paths

Place(s) to searching from (Array.<string> or string, default: process.cwd()).

callback

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

findDownOne(tests[, paths][, callback])

Like findDown, but either calls callback with the first found file or null, or returns a promise that resolved to a file or null.

function test(file, stats)

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

Returns
  • true or INCLUDE — Include the file in the results
  • SKIP — Do not search inside this directory
  • BREAK — Stop searching for files
  • anything else is ignored: files are neither included nor skipped

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

Contribute

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.

License

MIT © Titus Wormer

Current Tags

  • 6.0.0                                ...           latest (5 years ago)

11 Versions

  • 6.0.0                                ...           5 years ago
  • 5.0.1                                ...           6 years ago
  • 5.0.0                                ...           7 years ago
  • 4.0.1                                ...           7 years ago
  • 4.0.0                                ...           7 years ago
  • 3.0.0                                ...           8 years ago
  • 2.0.3                                ...           8 years ago
  • 2.0.2                                ...           9 years ago
  • 2.0.1                                ...           10 years ago
  • 2.0.0                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (10)
Dependents (4)

Copyright 2013 - present © cnpmjs.org | Home |