-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Add possibility to remove hook #53
Conversation
This creates the --remove|-r command to unlink a previously set hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending the PR @thibmaek, small comments! 👍
src/gitmoji.js
Outdated
@@ -75,6 +75,24 @@ class GitmojiCli { | |||
}; | |||
} | |||
|
|||
remove() { | |||
const hookFile = 'prepare-commit-msg'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you delete hookFile
and path
constants from remove()
and init methods()
and create a global commitHookPath
constant outside the class. Code duplication is dangerous!
src/gitmoji.js
Outdated
@@ -75,6 +75,24 @@ class GitmojiCli { | |||
}; | |||
} | |||
|
|||
remove() { | |||
const hookFile = 'prepare-commit-msg'; | |||
const path = `${process.env.PWD}/.git/hooks/${hookFile}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as hookFile ☝️
As requested in #53 (review)
Sure, think I fixed it now. |
Great! Take a look at the build @thibmaek the tests are failing 🚨 |
Woops, you're right! Totally forgot to update the test property but should be fine now. Also added a path check for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Thanks for your time @thibmaek 🚀
Description
Introduces the new command
--remove|-r
to unlink a previously set hook. Avoids having to dive into the .git dir in a terminal and remove it there. I love Gitmoji, but sometimes needed to remove it for projects where other people didn't want to use it.It uses
fs#unlink
which is an async method that takes the path and a completion callback. Very much likefs#writeFile
.Tests