@@ -29,33 +29,33 @@ export default command({
2929 parameters : [ '<install/uninstall>' ] ,
3030} , ( argv ) => {
3131 ( async ( ) => {
32- await assertGitRepo ( ) ;
33-
32+ const gitRepoPath = await assertGitRepo ( ) ;
3433 const { installUninstall : mode } = argv . _ ;
3534
36- const hookExists = await fileExists ( symlinkPath ) ;
35+ const absoltueSymlinkPath = path . join ( gitRepoPath , symlinkPath ) ;
36+ const hookExists = await fileExists ( absoltueSymlinkPath ) ;
3737 if ( mode === 'install' ) {
3838 if ( hookExists ) {
3939 // If the symlink is broken, it will throw an error
4040 // eslint-disable-next-line @typescript-eslint/no-empty-function
41- const realpath = await fs . realpath ( symlinkPath ) . catch ( ( ) => { } ) ;
41+ const realpath = await fs . realpath ( absoltueSymlinkPath ) . catch ( ( ) => { } ) ;
4242 if ( realpath === hookPath ) {
4343 console . warn ( 'The hook is already installed' ) ;
4444 return ;
4545 }
4646 throw new KnownError ( `A different ${ hookName } hook seems to be installed. Please remove it before installing aicommits.` ) ;
4747 }
4848
49- await fs . mkdir ( path . dirname ( symlinkPath ) , { recursive : true } ) ;
49+ await fs . mkdir ( path . dirname ( absoltueSymlinkPath ) , { recursive : true } ) ;
5050
5151 if ( isWindows ) {
5252 await fs . writeFile (
53- symlinkPath ,
53+ absoltueSymlinkPath ,
5454 windowsHook ,
5555 ) ;
5656 } else {
57- await fs . symlink ( hookPath , symlinkPath , 'file' ) ;
58- await fs . chmod ( symlinkPath , 0o755 ) ;
57+ await fs . symlink ( hookPath , absoltueSymlinkPath , 'file' ) ;
58+ await fs . chmod ( absoltueSymlinkPath , 0o755 ) ;
5959 }
6060 console . log ( `${ green ( '✔' ) } Hook installed` ) ;
6161 return ;
@@ -68,20 +68,20 @@ export default command({
6868 }
6969
7070 if ( isWindows ) {
71- const scriptContent = await fs . readFile ( symlinkPath , 'utf8' ) ;
71+ const scriptContent = await fs . readFile ( absoltueSymlinkPath , 'utf8' ) ;
7272 if ( scriptContent !== windowsHook ) {
7373 console . warn ( 'Hook is not installed' ) ;
7474 return ;
7575 }
7676 } else {
77- const realpath = await fs . realpath ( symlinkPath ) ;
77+ const realpath = await fs . realpath ( absoltueSymlinkPath ) ;
7878 if ( realpath !== hookPath ) {
7979 console . warn ( 'Hook is not installed' ) ;
8080 return ;
8181 }
8282 }
8383
84- await fs . rm ( symlinkPath ) ;
84+ await fs . rm ( absoltueSymlinkPath ) ;
8585 console . log ( `${ green ( '✔' ) } Hook uninstalled` ) ;
8686 return ;
8787 }
0 commit comments