bun-git-hooks 0.2.12 โ 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -10
- package/dist/bin/cli.js +5152 -594
- package/dist/bin/git-hooks.d.ts +13 -4
- package/dist/bin/types.d.ts +10 -37
- package/dist/git-hooks.d.ts +13 -4
- package/dist/index.js +4704 -507
- package/dist/types.d.ts +10 -37
- package/package.json +6 -17
package/README.md
CHANGED
|
@@ -12,16 +12,17 @@
|
|
|
12
12
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
|
-
- ๐ฏ **Simple Configuration
|
|
16
|
-
- ๐ **Automatic Installation
|
|
17
|
-
- ๐ก๏ธ **Type Safe
|
|
18
|
-
- ๐ง **Flexible Config
|
|
19
|
-
- ๐ช **Robust
|
|
20
|
-
- ๐ซ **Skip Option
|
|
21
|
-
- ๐งน **Cleanup
|
|
22
|
-
- ๐ฆ **Zero Dependencies
|
|
23
|
-
- โก **Fast
|
|
24
|
-
- ๐ **Verbose Mode
|
|
15
|
+
- ๐ฏ **Simple Configuration** _Easy setup through multiple config file formats_
|
|
16
|
+
- ๐ **Automatic Installation** _Hooks are installed on package installation_
|
|
17
|
+
- ๐ก๏ธ **Type Safe** _Written in TypeScript with comprehensive type definitions_
|
|
18
|
+
- ๐ง **Flexible Config** _Supports `.ts`, `.js`, `.mjs`, `.json` configurations_
|
|
19
|
+
- ๐ช **Robust** _Handles complex Git workspace configurations_
|
|
20
|
+
- ๐ซ **Skip Option** _Environment variable to skip hook installation_
|
|
21
|
+
- ๐งน **Cleanup** _Optional cleanup of unused hooks_
|
|
22
|
+
- ๐ฆ **Zero Dependencies** _Minimal footprint_
|
|
23
|
+
- โก **Fast** _Built for Bun with performance in mind_
|
|
24
|
+
- ๐ **Verbose Mode** _Detailed logging for troubleshooting_
|
|
25
|
+
- ๐ **Staged Lint** _Run commands only on staged files that match specific patterns_
|
|
25
26
|
|
|
26
27
|
## Installation
|
|
27
28
|
|
|
@@ -79,6 +80,9 @@ git-hooks uninstall
|
|
|
79
80
|
|
|
80
81
|
# Enable verbose logging
|
|
81
82
|
git-hooks --verbose
|
|
83
|
+
|
|
84
|
+
# Run staged lint for a specific hook manually
|
|
85
|
+
git-hooks run-staged-lint pre-commit
|
|
82
86
|
```
|
|
83
87
|
|
|
84
88
|
### Environment Variables
|
|
@@ -115,6 +119,73 @@ export default {
|
|
|
115
119
|
}
|
|
116
120
|
```
|
|
117
121
|
|
|
122
|
+
### Staged Lint (Lint Only Changed Files)
|
|
123
|
+
|
|
124
|
+
You can run linters and formatters only on staged files that match specific patterns, similar to lint-staged. This is particularly useful in pre-commit hooks to ensure quality checks run only on the files being committed.
|
|
125
|
+
|
|
126
|
+
#### Configuration
|
|
127
|
+
|
|
128
|
+
Add a `stagedLint` property to your hook configuration:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
// git-hooks.config.ts
|
|
132
|
+
export default {
|
|
133
|
+
'pre-commit': {
|
|
134
|
+
stagedLint: {
|
|
135
|
+
'*.js': 'eslint --fix',
|
|
136
|
+
'*.{ts,tsx}': ['eslint --fix', 'prettier --write'],
|
|
137
|
+
'*.css': 'stylelint --fix',
|
|
138
|
+
'*.md': 'prettier --write'
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
'verbose': true
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Manual CLI Usage
|
|
146
|
+
|
|
147
|
+
You can also run the staged lint manually using the CLI:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Run staged lint for pre-commit
|
|
151
|
+
git-hooks run-staged-lint pre-commit
|
|
152
|
+
|
|
153
|
+
# Run with verbose output
|
|
154
|
+
git-hooks run-staged-lint pre-commit --verbose
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### Pattern Matching
|
|
158
|
+
|
|
159
|
+
For each file pattern, you can specify either a single command or an array of commands that will run in sequence. The commands will only receive the staged files that match the pattern.
|
|
160
|
+
|
|
161
|
+
For example:
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
// git-hooks.config.ts
|
|
165
|
+
export default {
|
|
166
|
+
'*.{js,jsx}': 'eslint --fix', // Run eslint only on JavaScript files
|
|
167
|
+
'*.{ts,tsx}': ['eslint --fix', 'prettier --write'], // Run eslint and then prettier on TypeScript files
|
|
168
|
+
'*.css': 'stylelint --fix', // Run stylelint only on CSS files
|
|
169
|
+
'*.md': 'prettier --write' // Run prettier only on Markdown files
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The output will show which files are being processed and which tasks are being run:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
$ git commit
|
|
177
|
+
|
|
178
|
+
โฏ Running tasks for staged files...
|
|
179
|
+
โฏ *.js โ 2 files
|
|
180
|
+
โ ผ eslint --fix
|
|
181
|
+
โฏ *.{ts,tsx} โ 3 files
|
|
182
|
+
โ น eslint --fix
|
|
183
|
+
โ น prettier --write
|
|
184
|
+
โฏ *.css โ 1 file
|
|
185
|
+
โ ผ stylelint --fix
|
|
186
|
+
โฏ *.md โ no files [SKIPPED]
|
|
187
|
+
```
|
|
188
|
+
|
|
118
189
|
### Error Handling
|
|
119
190
|
|
|
120
191
|
The library provides clear error messages:
|