question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically sync emojis list

See original GitHub issue

Hey, this lib becomes out of sync whenever gitmoji adds a new emoji. Here’s how I managed to solve the problem.

  • Add gitmoji to the dev dependencies. Unfortunately gitmoji is not available from NPM, so we must point to the GitHub repo.
    "gitmoji": "carloscuesta/gitmoji",
  • Change the commitlint config file:
const { gitmojis } = require('gitmoji/src/data/gitmojis.json')
const allGitmojiCodes = gitmojis.map(gitmoji => gitmoji.code)

module.exports = {
  rules: {
    'type-enum': [2, 'always', allGitmojiCodes],

What do you think? Would you like a PR?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
gustavopchcommented, Feb 15, 2020

Downside of the approach above is that it will install all dependencies from the gitmoji repository. Almost doubled the contents of my yarn.lock file 😨.

I have another idea. We can download the gitmojis.json file from GitHub and place it in os.tmpdir(). Next time, if the file already exists, skip the download.

const downloadSync = (url, targetPath) => {
  const result = require('child_process').execFileSync('curl', ['--silent', '-L', url], {
    encoding: 'utf8',
    maxBuffer: Infinity,
  })

  fs.writeFileSync(targetPath, result)
}

const filePath = join(os.tmpdir(), 'gitmojis.json')

// Download gitmoji.json if not already downloaded
if (!fs.existsSync(filePath)) {
  downloadSync('https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json', filePath)
}

const { gitmojis } = require(filePath)
const allGitmojiCodes = gitmojis.map(gitmoji => gitmoji.code)

module.exports = {
  rules: {
    'type-enum': [2, 'always', allGitmojiCodes],

Now in order to update the list of emojis the user only needs to rm /tmp/gitmojis.json (so that it’ll be downloaded again next time commitlint runs). Or maybe we should keep the file at join(__dirname, 'gitmojis.json') // => "node_modules/commitlint-config-gitmoji/gitmojis.json" so that deleting the node_modules folder will also delete it (which seems to be what users would expect).

1reaction
khaosdoctorcommented, Feb 15, 2020

The second approach is better in my opinion

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatically Controlled Emoji-List - Pepe Manager Docs
The first thing you want to do is create a channel for your emoji list. This will be the final channel, so set...
Read more >
Use emoji and symbols on Mac - Apple Support
On your Mac, enter emoji, symbols, and other special characters using the Character ... To change the categories shown in the viewer, choose...
Read more >
Adding Emojis to Outlook's AutoCorrect - Slipstick Systems
Find the Emoji you want to use and copy it. · Open the Autocorrect dialog (File, Options, Mail, Spelling and Autocorrect, AutoCorrect Options)....
Read more >
Why am I seeing emojis under my "frequently used" section ...
The list of frequently used emoji is literally a list of emojis that you've used most often. This list does not synchronise over...
Read more >
Use emoji and reactions - Slack
An emoji reaction can often replace the need for a follow-up message. You can hover over or tap and hold reactions in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found