A utility to find, read and parse the content of the nearest .gitignore
file in the current or parent directories.
To use gitignore-reader
, install it via npm:
npm i -D gitignore-reader
# or
yarn add -D gitignore-reader
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.')
}
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
.gitignore
file, ornull
if not found.
Reads and parses the content of the nearest .gitignore
file.
-
maxMoves
: The maximum number of parent directories to search for the.gitignore
file (default is 3). - Returns an array of lines from the
.gitignore
file, excluding empty lines and comments.
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-changelog
Now 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 cz
A project by Stilearning © 2024.