# find-files-extra

> Simple file finder with both file name and content search options

Latest version **1.2.2** (published 2023-01-31) · The Unlicense license · 0 weekly downloads

## Install

```sh
npm install find-files-extra
pnpm add find-files-extra
yarn add find-files-extra
bun add find-files-extra
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2023-01-31 |
| First published | 2021-12-03 |
| Weekly downloads | 0 |
| License | The Unlicense |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 29.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alfnielsen@gmail.com |
| Maintainers | alfnielsen |
| Keywords | find files, find, file, io |

## Links

- npm: https://www.npmjs.com/package/find-files-extra
- Repository: https://github.com/alfnielsen/findFilesExtra
- Homepage: https://github.com/alfnielsen/findFilesExtra#readme
- Issues: https://github.com/alfnielsen/findFilesExtra/issues
- npm.io page: https://npm.io/package/find-files-extra

## Dependencies (3)

- [path](https://npm.io/package/path.md) ^0.12.7
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.0
- [glob-promise](https://npm.io/package/glob-promise.md) ^4.2.2

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2023-01-31
- 1.2.1 — 2023-01-21
- 1.2.0 — 2021-12-10
- 1.1.0 — 2021-12-10
- 1.0.3 — 2021-12-03
- 1.0.2 — 2021-12-03
- 1.0.1 — 2021-12-03
- 1.0.0 — 2021-12-03

## README

Simple (with advanced feature) file search

## Examples

```ts
// Find all json files (Loading content + parse to json)
let jsonFiles = await findFileExtra({
  root: MY_PROJECT_ROOT,
  filePattern: "**/*.json",
  loadFileContent: true,
  parseJson: true,
});

// Find all ts files with 'search-me' in content (Not loading content)
let files = await findFileExtra({
  root: MY_PROJECT_ROOT,
  filePattern: "**/*.ts",
  fileContentPattern: "search-me",
});

// Find all ts files with content that match regexp (Loading content)
let files = await findFileExtra({
  root: MY_PROJECT_ROOT,
  filePattern: "**/*.ts",
  fileContentPattern: /search\-me|searchMe/,
  loadFileContent: true,
});
```

## Result

The result is list of `findFileExtraFileInfo` _(interface)_

```ts
export interface findFileExtraFileInfo {
  fullPath: string;
  pathFromRoot: string;
  fileName: string;
  dirFullPath: string;
  dirPathFromRoot: string;
  ext: string;
  json?: unknown;
  content?: string;
}
```

## Options

| Option             | Required | Type            | Default                                            | Description                                                                                    |
| ------------------ | -------- | --------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| root               | true     | string          | -                                                  | Root directory to search in.                                                                   |
| filePattern        | false    | string          | `"**/*.*"`                                         | File pattern to search for. [glob pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>) |
| ignoreFilePattern  | false    | string[]        | `["**/bin/**", "**/node_modules/**", "**/obj/**"]` | File pattern to ignore. [glob pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>)     |
| fileContentPattern | false    | regexp / string | undefined                                          | File content pattern to search for.                                                            |
| loadFileContent    | false    | boolean         | false                                              | Load file content.                                                                             |
| parseJson          | false    | boolean         | false                                              | Parse file content to json.                                                                    |
| dot                | false    | boolean         | true                                               | Use dot notation for json keys.                                                                |
| nocase             | false    | boolean         | true                                               | Case insensitive search.                                                                       |

> `parseJson` requires `loadFileContent` to be true.

> if `filePattern` and `fileContentPattern` is both `undefined` (not set) all files will be found in the root.

## Installation

> - npm install find-files-extra

> - yarn add find-files-extra

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