Skip to content

Commit

Permalink
Make pre-commit hook symlink relative
Browse files Browse the repository at this point in the history
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 <kevin@kevinlocke.name>
  • Loading branch information
kevinoid committed Feb 6, 2016
1 parent 2ca2fb9 commit 1a04430
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion install.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ catch (e) {}
// installation of this module to completely fail. We should just output the
// error instead destroying the whole npm install process.
//
try { fs.symlinkSync(hook, precommit, 'file'); }
try { fs.symlinkSync(path.relative(hooks, hook), precommit, 'file'); }
catch (e) {
console.error('pre-commit:');
console.error('pre-commit: Failed to symlink the hook file in your .git/hooks folder because:');
Expand Down

0 comments on commit 1a04430

Please sign in to comment.