forked from thelounge/thelounge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-emoji.js
39 lines (31 loc) · 1.07 KB
/
generate-emoji.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"use strict";
const got = require("got");
const path = require("path");
const fs = require("fs");
// same regex as found in client/../parse.js
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]|\u{fe0f}/gu;
(async () => {
const response = await got(
"https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json"
);
const emojiStrategy = JSON.parse(response.body);
const emojiMap = {};
const fullNameEmojiMap = {};
for (const emoji of emojiStrategy) {
const cleanEmoji = emoji.emoji.replace(emojiModifiersRegex, "");
fullNameEmojiMap[cleanEmoji] = emoji.description;
for (const alias of emoji.aliases) {
emojiMap[alias] = emoji.emoji;
}
}
const emojiMapOutput = JSON.stringify(emojiMap, null, 2) + "\n";
const fullNameEmojiMapOutput = JSON.stringify(fullNameEmojiMap, null, 2) + "\n";
fs.writeFileSync(
path.resolve(path.join(__dirname, "..", "client", "js", "helpers", "simplemap.json")),
emojiMapOutput
);
fs.writeFileSync(
path.resolve(path.join(__dirname, "..", "client", "js", "helpers", "fullnamemap.json")),
fullNameEmojiMapOutput
);
})();