# find-in-files

> A simple tool to search text patterns across multiple files

Latest version **0.5.0** (published 2018-02-06) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2018-02-06 |
| First published | 2014-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/find-in-files) |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 58 |
| Author | Philipp Nowinski |
| Maintainers | kaesetoast |
| Keywords | search, find, files |

## Links

- npm: https://www.npmjs.com/package/find-in-files
- Repository: https://github.com/kaesetoast/find-in-files
- Issues: https://github.com/kaesetoast/find-in-files/issues
- npm.io page: https://npm.io/package/find-in-files

## Dependencies (2)

- [q](https://npm.io/package/q.md) ^1.0.1
- [find](https://npm.io/package/find.md) ^0.1.5

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.5.0 (latest) — 2018-02-06
- 0.4.0 — 2017-03-20
- 0.3.1 — 2016-04-11
- 0.2.1 — 2016-03-24
- 0.1.2 — 2015-09-19
- 0.1.1 — 2014-12-02
- 0.1.0 — 2014-06-26

## README

find-in-files [![Build Status](https://travis-ci.org/kaesetoast/find-in-files.svg?branch=master)](https://travis-ci.org/kaesetoast/find-in-files) [![Coverage Status](https://img.shields.io/coveralls/kaesetoast/find-in-files.svg)](https://coveralls.io/r/kaesetoast/find-in-files)
=============

A simple tool to search text patterns across multiple files

## Installation
find-in-files is a node module available via npm. You can install it with
```
$ npm install --save find-in-files
```

## Usage
The module exposes two simple functions which expect three parameters each.

```JavaScript
// Async
find(pattern, directory, fileFilter)
// Sync
findSync(pattern, directory, fileFilter)
```

#### pattern [string|object]
The string you want to search for or object to control regex flags

#### directory [string]
The directory you want to search in.

#### fileFilter [regex] \(optional)
A regex you can pass in to only search in files matching the filter.

```JavaScript
var findInFiles = require('find-in-files');
```

Both functions return a promise which will receive the results object. The results object contains the matches, count of matches per file and the lines that match.

```JavaScript
{
    'fileOne.txt': {
        matches: ['found string'],
        count: 1,
        lines: ['This line contains a found string.']
    }
}
```

## Example

```JavaScript
findInFiles.find("I'm Brian, and so's my wife!", '.', '.txt$')
    .then(function(results) {
        for (var result in results) {
            var res = results[result];
            console.log(
                'found "' + res.matches[0] + '" ' + res.count
                + ' times in "' + result + '"'
            );
        }
    });
```

```JavaScript
// Use object to set flags on regular expression. This one will ignore case.
findInFiles.find({'term': "I'm Brian, and so's my wife!", 'flags': 'ig'}, '.', '.txt$')
    .then(function(results) {
        for (var result in results) {
            var res = results[result];
            console.log(
                'found "' + res.matches[0] + '" ' + res.count
                + ' times in "' + result + '"'
            );
        }
    });
```

## License

MIT © [Philipp Nowinski](http://philippnowinski.de)

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