Alexandro.Net

Version 1.0.0

@stackline/vfile-find-up

vfile utility to find one or more files by searching the file system upwards

Independent maintenance of vfile-find-up 6.1.0. Original authors and licenses are retained.

Installation

# Preserve existing imports with an npm alias
npm install vfile-find-up@npm:@stackline/vfile-find-up@1.0.0
# Or use the scoped package name in your imports
npm install @stackline/vfile-find-up@1.0.0

Node.js: See compatibility notes. Read the compatibility and maintenance notes before migrating.

Usage and API

The reference below may retain upstream package names. Use the alias installation above to run those imports with this Stackline release.

@stackline/vfile-find-up

Independent maintenance fork of vfile-find-up@6.1.0, preserving its API and published type declarations.

npm install @stackline/vfile-find-up
# Keep existing imports:
npm install vfile-find-up@npm:@stackline/vfile-find-up@1.0.0

Stackline ยท Issues ยท Community

See UPSTREAM.md for source identity and issue review, and CHANGELOG.md for maintenance changes. Functional tests also run against the final npm tarball; releases are published from GitHub Actions with provenance.

Upstream documentation

vfile-find-up

Build Coverage Downloads Sponsors Backers Chat

vfile utility to find files by searching the file system upwards.

Contents

What is this?

This utility lets you find one or many files upwards.

When should I use this?

You can use this utility if you want to find, say, a config file. If you instead want to find files downwards, such as all markdown files in a folder, you can use vfile-find-down.

Install

This package is ESM only. In Node.js (version 14.14+ and 16.0+), install with npm:

npm install vfile-find-up

Use

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

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

Yields:

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

API

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

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

Find files or folders upwards.

๐Ÿ‘‰ Note: files are not read (their value is not populated).

Signatures
Parameters
Returns

Nothing when callback is given (void), otherwise a promise that resolves to files (Array<VFile>).

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

Find the first file or folder upwards.

๐Ÿ‘‰ Note: files are not read (their value is not populated).

Signatures
Parameters
Returns

Nothing when callback is given (void), otherwise a promise that resolves to a file (VFile | null).

BREAK

Stop searching (number).

INCLUDE

Include this file (number).

Assert

Handle a file (TypeScript type).

Parameters
Returns

How to handle this file (boolean | number, optional).

true is treated as INCLUDE.

Callback

Callback called when done (TypeScript type).

Parameters
Returns

Nothing (void).

CallbackOne

Callback called when done finding one file (TypeScript type).

Parameters
Returns

Nothing (void).

Test

Things to search for (TypeScript type).

For strings, the basename or extname of files must match them. For arrays, any test in them must match.

Type
type Test = Array<Assert | string> | Assert | string

Types

This package is fully typed with TypeScript. It exports the additional types Assert, Callback, CallbackOne, and Test.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.

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

Upstream issues and maintenance review

Upstream review

Independent fork of vfile-find-up@6.1.0, retaining source and license at https://github.com/vfile/vfile-find-up/tree/aaa6c93ff500014dc0e52405638eab83a2e1d833. The current queried open-issue list contained no issues. No runtime bug fix is claimed. File-search tests include the new maintenance documentation in their expected repository fixtures; all API and type surfaces are preserved and checked against the original npm artifact.

Release changes

Changelog

1.0.0

Release files and references

Package bytes, npm provenance and the immutable GitHub release were verified for this version. Security checks describe the reviewed release; documented compatibility risks and upstream reports are not blanket claims of resolution.