1- #!/usr/bin/env node
1+ #!/usr/bin/env bun
22import process from 'node:process'
33import { CAC } from 'cac'
44import { version } from '../package.json'
@@ -16,17 +16,24 @@ if (['1', 'true'].includes(SKIP_INSTALL_GIT_HOOKS || '')) {
1616cli
1717 . command ( '[configPath]' , 'Install git hooks, optionally from specified config file' )
1818 . 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' )
2222 . action ( async ( configPath ?: string , options ?: { verbose ?: boolean } ) => {
2323 try {
2424 if ( options ?. verbose ) {
2525 console . log ( '[DEBUG] Config path:' , configPath || 'using default' )
2626 console . log ( '[DEBUG] Working directory:' , process . cwd ( ) )
2727 }
2828
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+
3037 console . log ( '[INFO] Successfully set all git hooks' )
3138 }
3239 catch ( err ) {
3744
3845cli
3946 . command ( 'uninstall' , 'Remove all git hooks' )
40- . alias ( 'remove' ) // Add alias for uninstall
47+ . alias ( 'remove' )
4148 . 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' )
4552 . action ( async ( options ?: { verbose ?: boolean } ) => {
4653 try {
4754 if ( options ?. verbose ) {
5966
6067cli . version ( version )
6168cli . help ( )
69+
70+ // Parse CLI args
6271cli . parse ( )
0 commit comments