hardlounge/scripts/generate-emoji.js

42 lines
926 B
JavaScript
Raw Normal View History

"use strict";
2019-04-15 16:19:50 +00:00
const got = require("got");
const path = require("path");
const fs = require("fs");
2019-04-15 16:19:50 +00:00
(async () => {
2019-06-10 19:14:11 +00:00
const response = await got("https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json");
2019-04-15 16:19:50 +00:00
const emojiStrategy = JSON.parse(response.body);
const emojiMap = {};
2018-03-09 22:00:16 +00:00
const fullNameEmojiMap = {};
2019-06-10 19:14:11 +00:00
for (const emoji of emojiStrategy) {
fullNameEmojiMap[emoji.emoji] = emoji.description;
2019-06-10 19:14:11 +00:00
for (const alias of emoji.aliases) {
emojiMap[alias] = emoji.emoji;
}
}
2018-03-09 22:00:16 +00:00
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"
2018-03-09 22:00:16 +00:00
)), emojiMapOutput);
fs.writeFileSync(path.resolve(path.join(
__dirname,
"..",
"client",
"js",
"libs",
"fullnamemap.json"
)), fullNameEmojiMapOutput);
2019-04-15 16:19:50 +00:00
})();