gitignore-reader
v1.0.1
Published
foobar
Maintainers
Readme
.gitignore Reader
A utility to find, read and parse the content of the nearest .gitignore file in the current or parent directories.
Install
To use gitignore-reader, install it via npm:
npm i -D gitignore-reader
# or
yarn add -D gitignore-readerUsage
import { findGitignore, readGitignore } from 'gitignore-reader'
// Find the nearest .gitignore file
const gitignorePath = findGitignore()
if (gitignorePath) {
console.log('Found .gitignore file:', gitignorePath)
} else {
console.log('No .gitignore file found.')
}
// Read and parse the content of the nearest .gitignore file
const gitignoreContent = readGitignore()
if (gitignoreContent.length > 0) {
console.log('Gitignore content:', gitignoreContent)
} else {
console.log('No content found in .gitignore file.')
}API
findGitignore(maxMoves?: number): string | null
Finds the nearest .gitignore file in the current or parent directories.
maxMoves: The maximum number of parent directories to search (default is 3).- Returns the path to the found
.gitignorefile, ornullif not found.
readGitignore(maxMoves?: number): string[]
Reads and parses the content of the nearest .gitignore file.
maxMoves: The maximum number of parent directories to search for the.gitignorefile (default is 3).- Returns an array of lines from the
.gitignorefile, excluding empty lines and comments.
Contributing
We 💛 issues.
When committing, please conform to the semantic-release commit standards. Please install commitizen and the adapter globally, if you have not already.
npm i -g commitizen cz-conventional-changelogNow you can use git cz or just cz instead of git commit when committing. You can also use git-cz, which is an alias for cz.
git add . && git czLicense
A project by Stilearning © 2024.
