git-ignore-check
v1.0.1
Published
CLI + API tool to check if a file is ignored by .gitignore
Downloads
8
Maintainers
Readme
git-ignore-check
🔍 A lightweight CLI + Node.js API to check if a file or directory is ignored by .gitignore.
📦 Features
- ✅ Simple and fast
.gitignoreevaluation - 🔧 Works programmatically or via CLI
- 🧩 Perfect for build scripts, CI pipelines, or git hooks
- 📁 Supports custom
.gitignorepaths and monorepos
When is this package actually useful?
This package provides programmatic access to .gitignore rules,
allowing scripts and tools to determine if files or folders are ignored by Git.
Use cases include:
Build scripts and bundlers Automatically exclude ignored files from processing (e.g., bundling, linting).
Pre-commit or pre-push Git hooks Skip running checks or tests on files ignored by Git to save time.
CI/CD pipelines Avoid deploying or analyzing files that are intentionally ignored.
Custom developer tools Build CLI utilities or editors that implement
.gitignorelogic without depending on Git.Cross-platform tooling Integrate
.gitignorebehavior into any Node.js environment, regardless of platform.Programmatic validation Enforce policies such as ensuring certain files are tracked or warning about committed ignored files automatically.
In summary, this package helps automate workflows by making .gitignore logic available to code and scripts.
🚀 Installation
Global CLI
npm install -g git-ignore-check🖥️ CLI Usage
git-ignore-check <file-or-directory-path>Example
git-ignore-check dist/bundle.jsOutput:
✅ IGNORED – The file is ignored by .gitignore
❌ NOT IGNORED – The file is tracked (not ignored)
🧑💻 Programmatic Usage
import { isIgnored } from "git-ignore-check";
const ignored = await isIgnored("dist/bundle.js");
console.log(ignored); // true or falseOptions
await isIgnored("path/to/file", {
rootDir: "/path/to/git/project", // optional, defaults to process.cwd()
});📝 License
This project is licensed under the MIT License.
📣 Author
Made with ❤️ by Manindra Bollam([email protected])
