0.0.1 • Published 6 months ago

@1n/fs-find v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

@1n/fs-find

Find a file or directory by walking up parent directories

Install

npm install @1n/fs-find

Usage

/
└── Users
    └── somebody
        ├── logo.png
        ├── src
        |   └── index.js
        └── foo
            └── bar
                ├── baz
                └── example.js

example.js

import { findUp } from '@1n/fs-find';

console.log(await findUp('logo.png'));
//=> '/Users/somebody/logo.png'

console.log(await findUp('src/index.js'));
//=> '/Users/somebody/src/index.js'

API

findUp(name, options?)

Returns a Promise for the found path or undefined if it could not be found.

findUpSync(name, options?)

Returns the found path or undefined if it could not be found.

name

Type: string

The name of the file or directory to find.

options

Type: object

cwd

Type: URL | string Default: process.cwd()

The directory to start from.

type

Type: string Default: file Values: file | directory | dir

The type of path to match.

stopAt

Type: URL | string Default: Root directory

A directory path where the search halts if no matches are found before reaching this point.

0.0.1

6 months ago