Skip to content

Commit

Permalink
✨ feat: choose random emoji if multiple are given
Browse files Browse the repository at this point in the history
  • Loading branch information
Rettend committed Oct 31, 2023
1 parent f9fdbdd commit e3ae229
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/emojis.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"release": "🔖",
"cleanup": "🧹",
"license": "📜",
"deps": "📦"
"deps": "📦",
"readme": "📕,📗,📘,📙"
},
"release": "🔖",
"cleanup": "🧹",
Expand Down
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export function eemojify(text: string, config: Config): string {
if (!emoji)
throw new Error(`Emoji for type "${type}" not found.`)

if (emoji.includes(','))
emoji = emoji.trim().split(',')[Math.floor(Math.random() * emoji.split(',').length)] ?? emoji

return config.format
.replace('{emoji}', emoji)
.replace('{type}', type)
Expand Down

0 comments on commit e3ae229

Please sign in to comment.