{"name":"cspell-gitignore","version":"10.3.2","keywords":["cspell","gitignore","glob"],"author":{"name":"Jason Dent","email":"jason@streetsidesoftware.nl"},"license":"MIT","_id":"cspell-gitignore@10.3.2","maintainers":[{"name":"jason-dent","email":"jason@streetsidesoftware.nl"}],"homepage":"https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-gitignore#readme","bugs":{"url":"https://github.com/streetsidesoftware/cspell/labels/cspell-gitignore"},"bin":{"cspell-gitignore":"bin.mjs"},"dist":{"shasum":"fd153896cbc5ea1f60a99b8a4efecf9a967e0abf","tarball":"http://registry-npm.ywwl.com/cspell-gitignore/download/cspell-gitignore-10.3.2.tgz","fileCount":18,"integrity":"sha512-AnfW9XMHOJ1BgEsapLn7VHV9KT+SuqtDEy0chQtHG/2ZcP2UOFJC8bHH35DUD2cYdBNhp5Dr6BHnvvCHgQE1+w==","signatures":[{"sig":"MEYCIQDPDYNF/IeA4N+nAHBVR2wnJRHJUM6z3Hx9dNKqQVMnZAIhAJmIv7+pOUgF/6rde1MnEw6pGKeUmyJKAuCRYkshEh2d","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQD/gmyNtcWIYlXgweMY5ym6yNR0QjIK6O6tTFR3tOGKYwIgElYqQmlOFyriA4ZjhPdlVbYDJIoWdnXcXOjRKEDS9sE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/cspell-gitignore@10.3.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":30503,"size":7961,"noattachment":false,"key":"/cspell-gitignore/-/cspell-gitignore-10.3.2.tgz"},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=22.18.0"},"exports":{".":{"import":"./dist/index.js"}},"gitHead":"d43b5ffd5fbb295fcfd06358cdfc7560b3a84a7f","scripts":{"test":"vitest run","build":"tsc -p .","clean":"shx rm -rf dist temp coverage \"*.tsbuildInfo\"","watch":"tsc -p . -w","coverage":"vitest run --coverage","test:watch":"vitest","clean-build":"pnpm run clean && pnpm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:deedb353-45be-402d-86d8-16df489213bd"}},"repository":{"url":"git+https://github.com/streetsidesoftware/cspell.git","type":"git","directory":"packages/cspell-gitignore"},"_npmVersion":"lerna/5.6.1/node@v24.20.0+x64 (linux)","description":"Gitignore Glob matcher for cspell","directories":{},"sideEffects":false,"_nodeVersion":"24.20.0","dependencies":{"cspell-io":"10.3.2","@cspell/url":"10.3.2","cspell-glob":"10.3.2"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cspell-gitignore_10.3.2_1789463046180_0.4801389281291393","host":"s3://npm-registry-packages-npm-production"},"readme":"# `cspell-gitignore`\n\nA library to assist reading and filtering out files matching glob patterns found in `.gitignore` files.\n\n## Install\n\n```sh\nnpm install -S cspell-gitignore\n```\n\n## Usage\n\n```ts\nimport { GitIgnore, findRepoRoot } from 'cspell-gitignore';\n\n// ...\n\nconst cwd = process.cwd();\nconst root = (await findRepoRoot(cwd)) || cwd;\nconst gitIgnore = new GitIgnore([root]);\n\nconst allFiles = glob('**');\n\nconst files = await gitIgnore.filterOutIgnored(allFiles);\n```\n\n## Logic\n\n- For each file, search for the `.gitignore` files in the directory hierarchy.\n- Stop at the root of the file's git repository, the nearest directory with a `.git` directory or file. Like `git`,\n  the `.gitignore` files of a repository do not apply to a worktree or submodule nested inside it.\n- Ignore any files that match the globs found in the `.gitignore` files.\n\nThe `.gitignore` globs are evaluated from highest to lowest, matching the `git` behavior.\n\nTo prevent searching higher in the directory hierarchy, specify roots:\n\n```ts\nconst gitIgnore = new GitIgnore([process.cwd()]);\n```\n\n## `cspell-gitignore` CLI\n\n`cspell-gitignore` provides a simple cli for debugging .gitignore issues.\n\nIn most cases it should provide the same output as `git check-ignore`.\n\n### Usage\n\n```text\nUsage cspell-gitignore [options] <files>\n\nCheck files against .gitignore\nCompare against git check-ignore -v -n <files>\n\nOptions:\n  -r, --root   Add a root to prevent searching for .gitignore files above the root if the file is under the root.\n               This option can be used multiple times to add multiple roots. The default root is the current\n               repository root determined by the `.git` directory.\n\nExample:\n  cspell-gitignore README.md\n  cspell-gitignore -r . node_modules\n\n```\n\n### Example:\n\n```sh\n$ cspell-gitignore -r . node_modules\n.gitignore:58:node_modules/       node_modules\n```\n","publish_time":1789463046265,"_cnpm_publish_time":1789463046265,"dist-tags":{"cspell5":"5.21.2","cspell5-next":"5.21.2-alpha.0","latest":"10.4.0","next":"10.4.0-alpha.1"}}