-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56d7b47
commit 4155faf
Showing
3 changed files
with
165 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const regex = [ | ||
{ | ||
regex: /(?<=^feat(\(.*\))?(:)?)\s/, | ||
emoji: ' ✨ ' | ||
}, | ||
{ | ||
regex: /(?<=^fix(\(.*\))?(:)?)\s/, | ||
emoji: ' 🐛 ' | ||
}, | ||
{ | ||
regex: /(?<=^docs(\(.*\))?(:)?)\s/, | ||
emoji: ' 📚 ' | ||
}, | ||
{ | ||
regex: /(?<=^style(\(.*\))?(:)?)\s/, | ||
emoji: ' 💎 ' | ||
}, | ||
{ | ||
regex: /(?<=^refactor(\(.*\))?(:)?)\s/, | ||
emoji: ' 📦 ' | ||
}, | ||
{ | ||
regex: /(?<=^perf(\(.*\))?(:)?)\s/, | ||
emoji: ' 🚀 ' | ||
}, | ||
{ | ||
regex: /(?<=^test(\(.*\))?(:)?)\s/, | ||
emoji: ' 🚨 ' | ||
}, | ||
{ | ||
regex: /(?<=^build(\(.*\))?(:)?)\s/, | ||
emoji: ' 👷 ' | ||
}, | ||
{ | ||
regex: /(?<=^ci(\(.*\))?(:)?)\s/, | ||
emoji: ' 💚 ' | ||
}, | ||
{ | ||
regex: /(?<=^chore(\(.*\))?(:)?)\s/, | ||
emoji: ' 🔧 ' | ||
}, | ||
{ | ||
regex: /(?<=^revert(\(.*\))?(:)?)\s/, | ||
emoji: ' ⏪ ' | ||
}, | ||
{ | ||
regex: /(?<=^release(\(.*\))?(:)?)\s/, | ||
emoji: ' 🏹 ' | ||
}, | ||
{ | ||
regex: /(?<=^dependabot(\(.*\))?(:)?)\s/, | ||
emoji: ' 📦 ' | ||
}, | ||
{ | ||
regex: /(?<=^first(\(.*\))?(:)?)\s/, | ||
emoji: ' 🎉 ' | ||
} | ||
] | ||
|
||
// Emojify a commit message | ||
function emojifyCommitMessage(commitMessage) { | ||
return regex.reduce((acc, { regex, emoji }) => { | ||
return acc.replace(regex, emoji) | ||
}, commitMessage) | ||
} | ||
|
||
// Allow this to be run as a script from the command line | ||
if (require.main === module) { | ||
const args = process.argv.slice(2) | ||
const commitMessage = args[0] | ||
console.log(emojifyCommitMessage(commitMessage)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
|
||
regex_emojis=( | ||
"(?<=^feat(\(.*\))?(:)?)\s|✨" | ||
"(?<=^fix(\(.*\))?(:)?)\s|🐛" | ||
"(?<=^docs(\(.*\))?(:)?)\s|📚" | ||
"(?<=^style(\(.*\))?(:)?)\s|💎" | ||
"(?<=^refactor(\(.*\))?(:)?)\s|📦" | ||
"(?<=^perf(\(.*\))?(:)?)\s|🚀" | ||
"(?<=^test(\(.*\))?(:)?)\s|🚨" | ||
"(?<=^build(\(.*\))?(:)?)\s|👷" | ||
"(?<=^ci(\(.*\))?(:)?)\s|💚" | ||
"(?<=^chore(\(.*\))(:)?)\s|🔧" | ||
"(?<=^revert(\(.*\))(:)?)\s|⏪" | ||
"(?<=^release(\(.*\))(:)?)\s|🏹" | ||
"(?<=^dependabot(\(.*\))(:)?)\s|📦" | ||
"(?<=^first(\(.*\))(:)?)\s|🎉" | ||
) | ||
|
||
tests=( | ||
"feat test" | ||
"feat: test" | ||
"feat(test) test" | ||
"feat(test): test" | ||
"fix test" | ||
"fix: test" | ||
"fix(test) test" | ||
"fix(test): test" | ||
"docs test" | ||
"docs: test" | ||
"docs(test) test" | ||
"docs(test): test" | ||
"style test" | ||
"style: test" | ||
"style(test) test" | ||
"style(test): test" | ||
"refactor test" | ||
"refactor: test" | ||
"refactor(test) test" | ||
"refactor(test): test" | ||
"perf test" | ||
"perf: test" | ||
"perf(test) test" | ||
"perf(test): test" | ||
"test test" | ||
"test: test" | ||
"test(test) test" | ||
"test(test): test" | ||
"build test" | ||
"build: test" | ||
"build(test) test" | ||
"build(test): test" | ||
"ci test" | ||
"ci: test" | ||
"ci(test) test" | ||
"ci(test): test" | ||
"chore test" | ||
"chore: test" | ||
"chore(test) test" | ||
"chore(test): test" | ||
"revert test" | ||
"revert: test" | ||
"revert(test) test" | ||
"revert(test): test" | ||
"release test" | ||
"release: test" | ||
"release(test) test" | ||
"release(test): test" | ||
"dependabot test" | ||
"dependabot: test" | ||
"dependabot(test) test" | ||
"dependabot(test): test" | ||
"first test" | ||
"first: test" | ||
"first(test) test" | ||
"first(test): test" | ||
) | ||
|
||
for test in "${tests[@]}"; do | ||
for regex_emoji in "${regex_emojis[@]}"; do | ||
regex="${regex_emoji%%|*}" | ||
emoji="${regex_emoji##*|}" | ||
|
||
if [[ "$test" =~ $regex ]]; then | ||
test="${test/$regex/$emoji}" | ||
echo "$test" | ||
fi | ||
done | ||
done |