https://github.com/chilijung/git-staged-filter-file-extension
get git staged files, and filter with file extension.
https://github.com/chilijung/git-staged-filter-file-extension
git git-staged
Last synced: 2 months ago
JSON representation
get git staged files, and filter with file extension.
- Host: GitHub
- URL: https://github.com/chilijung/git-staged-filter-file-extension
- Owner: chilijung
- License: mit
- Created: 2017-06-23T16:08:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-03T14:37:43.000Z (over 8 years ago)
- Last Synced: 2025-10-31T10:59:34.785Z (8 months ago)
- Topics: git, git-staged
- Language: TypeScript
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# git-staged-filter-file-extension
get git staged files, and filter with file extension.
## Install
```
npm install git-staged-filter-file-extension
```
## Usage
```ts
const filterFile = new GitFilterFile("./", {ext: ".wow"});
// multiple file extensions
// const filterFile = new GitFilterFile("./", {ext: [".wow", ".txt"]});
filterFile.start()
.then((filesArr) => {
// filesArr type is interface IFileStatus
// see interface in `./src/index.ts`
})
```
IFileStatus interface
```ts
export interface IFileStatus {
path: string;
// refs: https://git-scm.com/docs/git-diff
// A: addition of a file
// C: copy of a file into a new one
// D: deletion of a file
// M: modification of the contents or mode of a file
// R: renaming of a file
// T: change in the type of the file
// U: file is unmerged (you must complete the merge before it can be committed)
// X: "unknown" change type (most probably a bug, please report it)
status: "A" | "C" | "D" | "M" | "R" | "T" | "U" | "X";
}
```
## API
#### GitStagedFilterFile(<.git path>, options)
- .git path: where your git repo lives.
- options: should pass a object, like below.
- ext: file extensions, could be string or string array. For example `.js` or `['.js', '.jsx']`
- pattern: this will pass to `grep` command as pattern, you can also passed as an array will be pass as arguments to `grep` command.
```ts
export interface Ioptions {
ext?: string | string[]; // optional
pattern?: string | string[]; // optional
}
```