git
Git-derived file listings for the repo-walking scripts.
Tooling that walks the repository must skip whatever .gitignore skips — otherwise every script grows its own hand-maintained ignore list, the lists drift apart, and a path that is gitignored but not enumerated (a nested node_modules under a test fixture, say) is walked anyway. Most tools have a native switch for this; the ones that do not take a file list instead, and that is what this module produces.
Asking git rather than parsing .gitignore is deliberate: it honors nested ignore files, ! negations, .git/info/exclude, and the user’s global excludes, at no cost to us.
It also reads a tracked file as it is about to be COMMITTED (readIndexContent), for a gate that asserts something about those bytes. Such a gate typically runs from nano-staged beside lint:fix and format, which rewrite staged files in place, and nano-staged runs its per-pattern task groups with Promise.all, so a gate reading the working tree races the fixer. Reading the index makes the ordering irrelevant rather than enforced.
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| GetNonIgnoredFilesOptions | Options for getNonIgnoredFiles. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| getNonIgnoredFiles | Lists the repository files that .gitignore does not exclude. Covers both tracked files and untracked-but-not-ignored ones, so a brand-new file is checked before it is ever committed. |
| readIndexContent | Reads one tracked file’s content out of the git index - stage 0, the bytes git commit would write. This spawns git directly rather than going through execFromRoot, for two reasons, either of which alone would be enough: execFromRoot decodes stdout as UTF-8, which a binary blob does not survive, and it strips one trailing newline, so every text file would read as differing from its source by its last line. The path is passed in the :./<path> form, which git resolves against the directory it runs from rather than against the top of the working tree, so this stays correct when root is a subpackage of the repository rather than its top. No smudge filter or line-ending conversion is applied: git cat-file blob hands the blob back verbatim. |