2017-10-19 09:36:53 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-04-15 16:19:50 +00:00
|
|
|
const got = require("got");
|
2017-10-19 09:36:53 +00:00
|
|
|
const path = require("path");
|
|
|
|
const fs = require("fs");
|
|
|
|
|
2019-10-03 10:35:38 +00:00
|
|
|
// same regex as found in client/../parse.js
|
|
|
|
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]|\u{fe0f}/gu;
|
|
|
|
|
2019-04-15 16:19:50 +00:00
|
|
|
(async () => {
|
2019-07-17 09:33:59 +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);
|
2017-10-19 09:36:53 +00:00
|
|
|
const emojiMap = {};
|
2018-03-09 22:00:16 +00:00
|
|
|
const fullNameEmojiMap = {};
|
2017-10-19 09:36:53 +00:00
|
|
|
|
2019-06-10 19:14:11 +00:00
|
|
|
for (const emoji of emojiStrategy) {
|
2019-10-03 10:35:38 +00:00
|
|
|
const cleanEmoji = emoji.emoji.replace(emojiModifiersRegex, "");
|
|
|
|
fullNameEmojiMap[cleanEmoji] = emoji.description;
|
2017-10-19 09:36:53 +00:00
|
|
|
|
2019-06-10 19:14:11 +00:00
|
|
|
for (const alias of emoji.aliases) {
|
|
|
|
emojiMap[alias] = emoji.emoji;
|
2017-10-19 09:36:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-09 22:00:16 +00:00
|
|
|
const emojiMapOutput = JSON.stringify(emojiMap, null, 2) + "\n";
|
|
|
|
const fullNameEmojiMapOutput = JSON.stringify(fullNameEmojiMap, null, 2) + "\n";
|
2017-10-19 09:36:53 +00:00
|
|
|
|
2019-07-17 09:33:59 +00:00
|
|
|
fs.writeFileSync(
|
2019-11-05 10:36:44 +00:00
|
|
|
path.resolve(path.join(__dirname, "..", "client", "js", "helpers", "simplemap.json")),
|
2019-07-17 09:33:59 +00:00
|
|
|
emojiMapOutput
|
|
|
|
);
|
2018-03-09 22:00:16 +00:00
|
|
|
|
2019-07-17 09:33:59 +00:00
|
|
|
fs.writeFileSync(
|
2019-11-05 10:36:44 +00:00
|
|
|
path.resolve(path.join(__dirname, "..", "client", "js", "helpers", "fullnamemap.json")),
|
2019-07-17 09:33:59 +00:00
|
|
|
fullNameEmojiMapOutput
|
|
|
|
);
|
2019-04-15 16:19:50 +00:00
|
|
|
})();
|