Skip to content

Commit 1a04430

Browse files
committed
Make pre-commit hook symlink relative
Renaming or moving the project directory (the one containing .git) causes absolute links to break and the pre-commit hook to be silently ignored. Instead, make the link relative so that it is preserved across directory rename/move. Signed-off-by: Kevin Locke <[email protected]>
1 parent 2ca2fb9 commit 1a04430

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ catch (e) {}
5252
// installation of this module to completely fail. We should just output the
5353
// error instead destroying the whole npm install process.
5454
//
55-
try { fs.symlinkSync(hook, precommit, 'file'); }
55+
try { fs.symlinkSync(path.relative(hooks, hook), precommit, 'file'); }
5656
catch (e) {
5757
console.error('pre-commit:');
5858
console.error('pre-commit: Failed to symlink the hook file in your .git/hooks folder because:');

0 commit comments

Comments
 (0)