import { type Ignore } from "ignore"; /** * One level of the cascade ignore stack. Each level holds the rules from a * single `.gitignore` file (or the root extra-patterns), the absolute * directory those rules are anchored to, and a link to its parent level. * * Modeled after ripgrep's `ignore` crate * (https://docs.rs/ignore/latest/ignore/gitignore/), where each * `Gitignore` matcher records its own root and the parent chain is walked * at match time. We avoid `.gitignore` content rewriting that way: rules * stay verbatim, and the path-side is made relative to each matcher's * root before being tested. */ export type IgnoreChain = { /** Absolute directory the matcher is rooted at (native separators). */ dir: string; /** node-ignore matcher carrying ONLY this dir's rules. */ matcher: Ignore; /** Parent level, or null at the root. */ parent: IgnoreChain | null; }; /** * Build the root level of the cascade for a walk rooted at `cwd`. * `extraPatterns` are evaluated at the root, so they behave as if the * caller dropped a synthetic `.gitignore` at `cwd`. */ export declare const createRootIgnore: (cwd: string, extraPatterns: readonly string[]) => IgnoreChain; /** * Extend the chain with a new level for `dir`. If `dir` has no ignore file * (or all candidate files are empty), returns `parent` unchanged so callers * can avoid pushing no-op levels. * * `presentNames` is an optional pre-filter (e.g. derived from `Dirent[]`) * of the ignore-file names that actually exist in `dir`; when provided we * skip the readFile ENOENT round-trip for missing files entirely. */ export declare const extendIgnore: (parent: IgnoreChain, dir: string, ignoreFiles: readonly string[], presentNames?: ReadonlySet) => Promise; /** * Walk the chain root → leaf, asking each level whether it ignores the * given path. Each level computes the path relative to its own `dir` * before consulting its matcher (mirroring gitignore semantics: a rule * in `packages/foo/.gitignore` is anchored at `packages/foo/`). * * The verdict accumulates across levels: a later level can flip an earlier * one via a negation rule. node-ignore's `test()` exposes both `ignored` * and `unignored` so we can distinguish "this level made no statement" * from "this level un-ignored the path". * * `fullPath` is the absolute path to test (native separators OK). * `isDirectory` controls whether a trailing slash is appended for the * matcher (`foo` vs `foo/` are distinct in gitignore semantics). */ export declare const isIgnoredByChain: (chain: IgnoreChain, fullPath: string, isDirectory: boolean) => boolean; //# sourceMappingURL=ignore-stack.d.ts.map