# dat-ignore

> default ignore for dat

Latest version **2.1.3** (published 2022-01-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.3 |
| Published | 2022-01-06 |
| First published | 2017-03-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Dat Project contributors |
| Maintainers | karissa, maxogden, yoshuawuyts, mafintosh, jhand, rangermauve, leichtgewicht, the-real-dk, pfrazee, frando, cblgh, ninabreznik, serapath, zootella, juliangruber |
| Keywords | dat |

## Links

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

## Dependencies (1)

- [anymatch](https://npm.io/package/anymatch.md) ^2.0.0

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 2.1.3 (latest) — 2022-01-06
- 1.1.3 (old-version) — 2017-08-30
- 2.1.2 — 2019-02-20
- 2.1.1 — 2018-03-27
- 2.1.0 — 2018-03-19
- 2.0.0 — 2017-08-30
- 1.1.2 — 2017-08-03
- 1.1.1 — 2017-06-16
- 1.1.0 — 2017-06-14
- 1.0.0 — 2017-03-27
- 0.0.0 — 2017-03-27

## README

[![deprecated](http://badges.github.io/stability-badges/dist/deprecated.svg)](https://dat-ecosystem.org/) 

More info on active projects and modules at [dat-ecosystem.org](https://dat-ecosystem.org/) <img src="https://i.imgur.com/qZWlO1y.jpg" width="30" height="30" /> 

---

# dat-ignore

> default ignore for dat

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]

Check if a file should be ignored for Dat:

* Ignore `.dat` by default
* Use the `.datignore` file
* Optionally ignore all hidden files
* Add in other custom ignore matches

## Install

```
npm install dat-ignore
```

## Usage

```js
var datIgnore = require('dat-ignore')
var ignore = datIgnore('/data/dir')

console.log(ignore('.dat')) // true
console.log(ignore('.git')) // true
console.log(ignore('dat-data')) // false
console.log(ignore('cat.jpg')) // false
```

Uses [anymatch](https://github.com/es128/anymatch) to match file paths.

### Example Options

Common configuration options.

#### Add custom ignore

```js
var ignore = datIgnore('/data/dir', {
    ignore: [
      '**/node_modules/**', 
      'path/to/file.js',
      'path/anyjs/**/*.js'
    ]
  })
```

#### Allow Hidden Files

```js
var ignore = datIgnore('/data/dir', { ignoreHidden: false })
```

####  Change Dat Ignore Path

```js
var ignore = datIgnore('/data/dir', {
    datignorePath: '~/.datignore'
  })
```

#### `.datignore` as string/buffer

Pass in a string as a newline delimited list of things to ignore.

```js
var datIgnoreFile = fs.readFileSync('~/.datignore')
datIgnoreFile += '\n' + fs.readFileSync(path.join(dir, '.datignore'))
datIgnoreFile += '\n' + fs.readFileSync(path.join(dir, '.gitignore'))

var ignore = datIgnore('/data/dir', { datignore: datIgnoreFile })
```

## API

### `var ignore = datIgnore(dir, [opts])`

Returns a function that checks if a path should be ignored:

```js
ignore('.dat') // true
ignore('.git') // true
ignore('data/cats.csv') // false
```

#### `dir`

`dir` is the file root to compare to. It is also used to find `.datignore`, if not specified.

#### Options:

* `opts.ignore` - Extend custom ignore with any anymatch string or array.
* `opts.useDatIgnore` - Use the `.datignore` file in `dir` (default: true)
* `opts.ignoreHidden` - Ignore all hidden files/folders (default: true)
* `opts.datignorePath` - Path to `.datignore` file (default: `dir/.datignore`)
* `opts.datignore` - Pass `.datignore` as buffer or string

## License

[MIT](LICENSE.md)

[npm-image]: https://img.shields.io/npm/v/dat-ignore.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/dat-ignore
[travis-image]: https://img.shields.io/travis/datproject/dat-ignore.svg?style=flat-square
[travis-url]: https://travis-ci.org/datproject/dat-ignore
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard

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