ignore
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Ignore is a package implemented in Pure JavaScript which manages, filters and parses according to the .gitignore specification 2.22.1. This package is a go-to for managing and filtering .gitignore rules and is popularly used by several platforms like ESLint, GitBook, and many others. It stands out because it precisely follows the gitignore spec and can filter filenames according to a .gitignore file, providing an effective solution for anyone in need of this functionality.
To use ignore in your projects, installation is done from npm by running the command:
npm i ignore
Here is an example of how to use this package in your code:
Firstly, import ignore from 'ignore' and then initialize ignore and add rules you'll like to use.
import ignore from 'ignore'
const ig = ignore().add(['.abc/*', '!.abc/d/'])
// Adding rules to ignore
const paths = [
'.abc/a.js', // filtered out
'.abc/d/e.js' // included
]
// Using the filter() function on your paths
ig.filter(paths) // ['.abc/d/e.js']
// Verifying if a file will be ignored
ig.ignores('.abc/a.js') // true
You can also use ignore as a filter function for your paths:
paths.filter(ig.createFilter()); // ['.abc/d/e.js']
Ignore handles win32 paths as such:
ig.filter(['.abc\\a.js', '.abc\\d\\e.js'])
// if the code above runs on windows, the result will be
// ['.abc\\d\\e.js']
To access the documentation for ignore, you can find it in the readme of the repository at https://github.com/kaelzhang/node-ignore. It provides a comprehensive and detailed guide on how to use the package, its methods, options, upgrade guide, and collaborators. Please note that the accurate usage of ignore follows the gitignore specification 2.22.1.