commit-msg-must-use-emoji
v1.1.3
Published
π Easy-to-add Git hook that forces you to start every commit message with an emoji
Downloads
15
Maintainers
Readme
commit-msg-must-use-emoji
π Easy-to-add Git hook that forces you to start every commit message with an emoji
What is this?
Once you install this, whenever you try to commit and your message doesn't start with an emoji, your commit will fail and you'll be prompted to amend it. You can bypass it by adding --no-verify
to git commit
.
Why is this?
Lots of people seem interested in using emoji in Git commit messages, for various reasons. You can do this in some consistent way to communicate stuff, or you can just do it to add fun to the world (or both).
Emoji bring a lot of light to my life. Do I really want them in every commit message? I don't know; let's find out.
No other tool did exactly what I wanted here, so I thought I'd play around in the wild mire of zero width joiners and fulfill them myself:
- β¨ Emoji are unicode (no shortcodes!)
- ππ½ββοΈ Set it and forget it (Git hooks are simple.
package.json
scripts are simple.)
Installation
- If your project has a package.json
- If your project doesn't have a package.json (but Node is installed on your machine)
If your project has a package.json
The chillest way to install this tool is to use Husky. πΆ
Run npm install -D husky && npm install -D commit-msg-must-use-emoji
.
(yarn add -D husky && yarn add -D commit-msg-must-use-emoji
probably works too.)
Then add a commitmsg
script so your package.json
looks like:
{
"...
"scripts": {
...
"commitmsg": "commit-msg-must-use-emoji",
...
},
...
}
π
If you already have a commitmsg
Node script
You can require this package and test a commit message string or a commit message filename (Husky stores it in process.env.GIT_PARAMS
while a general Git hook node script will provide it as process.argv[2]
):
const startsWithEmoji = require('commit-msg-must-use-emoji');
// e.g.
const messageString = 'Update code';
const messageFilename = '/Users/me/project/.git/COMMIT_EDITMSG';
if (!startsWithEmoji.testString(messageString)) {
console.error('π‘')
}
// or
if (!startsWithEmoji.testString(messageFilename) {
console.error('πΏ');
}
π
If your project doesn't have a package.json (but Node is installed on your machine)
You can install this package globally (npm install -g commit-msg-must-use-emoji
or yarn global add commit-msg-must-use-emoji
) and then, as long as you're on a Unix machine and don't already have a commit-msg
Git hook, go to your project and try
echo '#!/usr/bin/env sh
commit-msg-must-use-emoji $1' > ./.git/hooks/commit-msg && \
chmod +x ./.git/hooks/commit-msg
π
If you want to add this to an existing commit-msg
shell script, adding commit-msg-must-use-emoji $1
somewhere in there will probably work. If you're on Windows, I'm not sure.
π» Thx
Thanks to all the emoji lovers, but interacting with the work of @notwaldorf, emojineer extraordinaire, has probably done the most to get me excited about emoji recently.