thelounge/scripts/generate-emoji.js
2019-06-10 22:17:00 +03:00

41 lines
926 B
JavaScript

"use strict";
const got = require("got");
const path = require("path");
const fs = require("fs");
(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) {
fullNameEmojiMap[emoji.emoji] = 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",
"libs",
"simplemap.json"
)), emojiMapOutput);
fs.writeFileSync(path.resolve(path.join(
__dirname,
"..",
"client",
"js",
"libs",
"fullnamemap.json"
)), fullNameEmojiMapOutput);
})();