# ignore-file

> Compile an ignore file (similar to .gitignore) to a Javascript function

Latest version **1.1.3** (published 2020-08-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install ignore-file
pnpm add ignore-file
yarn add ignore-file
bun add ignore-file
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2020-08-26 |
| First published | 2014-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Mathias Buus |
| Maintainers | mafintosh |
| Keywords | ignore, file, gitignore |

## Links

- npm: https://www.npmjs.com/package/ignore-file
- Repository: https://github.com/mafintosh/ignore-file
- Issues: https://github.com/mafintosh/ignore-file/issues
- npm.io page: https://npm.io/package/ignore-file

## Dependencies (1)

- [minimatch](https://npm.io/package/minimatch.md) ^3.0.4

## 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

- 1.1.3 (latest) — 2020-08-26
- 1.1.2 — 2014-08-15
- 1.1.1 — 2014-07-23
- 1.1.0 — 2014-05-30
- 1.0.0 — 2014-05-30
- 0.0.0 — 2014-05-30

## README

# ignore-file

Compile an ignore file (similar to .gitignore) to a Javascript function that returns `true` or `false` given a filename

```
npm install ignore-file
```

[![build status](http://img.shields.io/travis/mafintosh/ignore-file.svg?style=flat)](http://travis-ci.org/mafintosh/ignore-file)

## Usage

Assuming you have a `.gitignore` file in your current working directory that contains `node_modules` do

``` js
var ignore = require('ignore-file')

ignore('.gitignore', function(err, filter) {
  if (err) throw err
  console.log(filter('index.js'))     // returns false
  console.log(filter('node_modules')) // returns true
})
```

You can also use `ignore.sync(filename)` to synchroniously compile an ignore file
If the file doesn't exist `null` is returned. This allows you easily implement fallbacks

``` js
var filter = ignore.sync('.npmignore') || ignore.sync('.gitignore') || ignore.compile('node_modules')
```

The above will use `.npmignore` if it exists, else `.gitignore` and finally just ignore all `node_modules` folders

## License

MIT

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