1
- #!/usr/bin/env node
1
+ #!/usr/bin/env bun
2
2
import process from 'node:process'
3
3
import { CAC } from 'cac'
4
4
import { version } from '../package.json'
@@ -16,17 +16,24 @@ if (['1', 'true'].includes(SKIP_INSTALL_GIT_HOOKS || '')) {
16
16
cli
17
17
. command ( '[configPath]' , 'Install git hooks, optionally from specified config file' )
18
18
. option ( '--verbose' , 'Enable verbose logging' )
19
- . example ( 'bun- git-hooks' )
20
- . example ( 'bun- git-hooks ../src/config.ts' )
21
- . example ( 'bun- git-hooks --verbose' )
19
+ . example ( 'git-hooks' )
20
+ . example ( 'git-hooks ../src/config.ts' )
21
+ . example ( 'git-hooks --verbose' )
22
22
. action ( async ( configPath ?: string , options ?: { verbose ?: boolean } ) => {
23
23
try {
24
24
if ( options ?. verbose ) {
25
25
console . log ( '[DEBUG] Config path:' , configPath || 'using default' )
26
26
console . log ( '[DEBUG] Working directory:' , process . cwd ( ) )
27
27
}
28
28
29
- setHooksFromConfig ( process . cwd ( ) , { configFile : configPath } )
29
+ if ( configPath ) {
30
+ const config = await import ( configPath )
31
+ setHooksFromConfig ( process . cwd ( ) , { configFile : config } )
32
+ }
33
+ else {
34
+ setHooksFromConfig ( process . cwd ( ) )
35
+ }
36
+
30
37
console . log ( '[INFO] Successfully set all git hooks' )
31
38
}
32
39
catch ( err ) {
37
44
38
45
cli
39
46
. command ( 'uninstall' , 'Remove all git hooks' )
40
- . alias ( 'remove' ) // Add alias for uninstall
47
+ . alias ( 'remove' )
41
48
. option ( '--verbose' , 'Enable verbose logging' )
42
- . example ( 'bun- git-hooks uninstall' )
43
- . example ( 'bunx bun- git-hooks remove' )
44
- . example ( 'bunx git-hooks uninstall --verbose' )
49
+ . example ( 'git-hooks uninstall' )
50
+ . example ( 'git-hooks remove' )
51
+ . example ( 'git-hooks uninstall --verbose' )
45
52
. action ( async ( options ?: { verbose ?: boolean } ) => {
46
53
try {
47
54
if ( options ?. verbose ) {
59
66
60
67
cli . version ( version )
61
68
cli . help ( )
69
+
70
+ // Parse CLI args
62
71
cli . parse ( )
0 commit comments