# @fnet/up-list-files

Latest version **0.1.14** (published 2025-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fnet/up-list-files
pnpm add @fnet/up-list-files
yarn add @fnet/up-list-files
bun add @fnet/up-list-files
```

Provides the command `fnet-up-list-files`.

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.14 |
| Published | 2025-04-30 |
| First published | 2024-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 27.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gultekin Boyraz <gultekinboyraz@gmail.com> |
| Maintainers | serdar986, serdark, gboyraz |

## Links

- npm: https://www.npmjs.com/package/@fnet/up-list-files
- Repository: https://gitlab.com/fnetai/up-list-files
- npm.io page: https://npm.io/package/@fnet/up-list-files

## Dependencies (2)

- [@fnet/args](https://npm.io/package/@fnet/args.md) ^0.1
- [@fnet/list-files](https://npm.io/package/@fnet/list-files.md) ^0.1

## Recent versions

- 0.1.14 (latest) — 2025-04-30
- 0.1.13 — 2024-10-14
- 0.1.12 — 2024-10-14
- 0.1.11 — 2024-10-14
- 0.1.10 — 2024-10-14
- 0.1.9 — 2024-10-10
- 0.1.8 — 2024-10-10
- 0.1.7 — 2024-10-10
- 0.1.6 — 2024-10-10
- 0.1.5 — 2024-10-08
- 0.1.4 — 2024-10-08
- 0.1.3 — 2024-10-08
- 0.1.2 — 2024-10-08
- 0.1.1 — 2024-10-08

## README

# @fnet/up-list-files

## Introduction

The `@fnet/up-list-files` project is a utility designed to help users search for files within a specified directory or the current working directory if none is specified. It aims to provide a convenient way to locate files based on specific patterns, offering flexibility through various search options.

## How It Works

This tool operates by searching a given directory, or its parent directories if needed, to find files that match a provided pattern. You can specify the type of files you want to include or exclude by adjusting the search parameters such as directory depth, file visibility (including hidden files), and other pattern-related options.

## Key Features

- **Pattern Matching**: Search for files using patterns that can be specified as strings or arrays.
- **Directory Navigation**: Automatically climbs up directory levels in search of files that match the pattern.
- **File Type Filtering**: Can filter results to include only files or directories, depending on user preference.
- **Hidden Files**: Allows for inclusion or exclusion of hidden files in the search results.
- **Absolute Paths**: Optionally retrieves file paths as absolute or relative to the starting directory.

## Conclusion

`@fnet/up-list-files` serves as a practical tool for users looking to efficiently search for files based on specific patterns within a directory. With straightforward functionality and various customizable options, it helps in managing file searches with ease.


# Developer Guide for @fnet/up-list-files

## Overview

The `@fnet/up-list-files` library is a utility designed to help developers efficiently search and list files within a directory structure. By leveraging pattern matching similar to the `glob` package, it allows developers to specify patterns to find files, with options to control visibility, recursion, and path formats. This makes it ideal for any node.js project that requires file traversal and discovery.

## Installation

To include `@fnet/up-list-files` in your project, you can use either npm or yarn:

```bash
npm install @fnet/up-list-files
```

or

```bash
yarn add @fnet/up-list-files
```

## Usage

The main function provided by the library is the `index` function, which is used to list files in a directory structure based on specified patterns and options.

### Basic Usage

To utilize the library, you will need to import it and then call the `index` function with the desired parameters. Here’s an example:

```javascript
import listFiles from '@fnet/up-list-files';

const options = {
  dir: './src',            // Directory to start searching
  pattern: ['*.js'],       // Pattern to match files
  nodir: true,             // Do not include directories in results
  dot: true,               // Include dotfiles
  absolute: false,         // Return relative paths
  ignore: ['node_modules'],// Ignore specific paths
};

const files = listFiles(options);

console.log(files);
```

### Advanced Usage

For more specific needs, such as searching beyond the initial directory or requiring verbose logs during the file search, adjust the options as necessary:

```javascript
const options = {
  dir: './src',
  pattern: ['*.js', '*.jsx'],
  nodir: true,
  dot: true,
  absolute: true,        // Return absolute paths
  ignore: ['node_modules'],
  follow: true,          // Follow symbolic links
  matchBase: true,       // Match patterns against the base name
  verbose: true,         // Print directories as they are searched
};

const files = listFiles(options);

files.forEach(file => {
  console.log(`File found: ${file}`);
});
```

## Examples

Here are some scenarios showing how `@fnet/up-list-files` can be used:

**Example 1: Getting JavaScript files in a directory**

```javascript
const jsFiles = listFiles({
  dir: './lib',
  pattern: ['*.js'],
});
console.log(jsFiles);
```

**Example 2: Including dotfiles and searching recursively**

```javascript
const dotAndJsFiles = listFiles({
  dir: './app',
  pattern: ['*.js', '.*'],
  dot: true,
  follow: true,
});
console.log(dotAndJsFiles);
```

**Example 3: Ignoring specific directories**

```javascript
const filesExcludingNodeModules = listFiles({
  dir: './project',
  pattern: ['*'],
  ignore: ['node_modules', 'dist'],
});
console.log(filesExcludingNodeModules);
```

## Acknowledgement

This project builds upon concepts inspired by file pattern matching utilities and open-source software practices. We acknowledge contributions from the Node.js community in enhancing file system navigation capabilities.



# Input Schema

```yaml
$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  dir:
    type: string
    description: The directory to search in. Defaults to current working directory
      if not provided.
  pattern:
    oneOf:
      - type: string
        description: Glob pattern to match filenames, must be a relative path.
      - type: array
        items:
          type: string
          description: An array of glob patterns to match filenames, all must be relative
            paths.
    default:
      - "*"
    description: Pattern(s) to search for.
  nodir:
    type: boolean
    default: false
    description: When true, excludes directories from the results.
  dot:
    type: boolean
    default: true
    description: Include dotfiles in matching.
  absolute:
    type: boolean
    default: false
    description: When true, the results include absolute paths.
  ignore:
    oneOf:
      - type: string
        description: Pattern to ignore.
      - type: array
        items:
          type: string
          description: An array of patterns to ignore.
    description: Pattern(s) to ignore during search.
  follow:
    type: boolean
    default: false
    description: When true, follows symbolic links.
  matchBase:
    type: boolean
    default: false
    description: When true, performs matching based on the basename of the file.
  verbose:
    type: boolean
    default: false
    description: When true, enables verbose logging of the search process.
required: []

```

---
_Source: https://npm.io/package/@fnet/up-list-files · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
