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 CHANGED
@@ -12,16 +12,17 @@
12
12
 
13
13
  ## Features
14
14
 
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
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: