2017-06-28 12:35:14 +02:00
|
|
|
#!/usr/bin/env node
|
2019-05-19 16:23:43 +02:00
|
|
|
|
|
|
|
// This generates src/stripped-emoji.json as used by the EmojiProvider autocomplete
|
|
|
|
// provider.
|
|
|
|
|
2019-05-19 21:48:18 +02:00
|
|
|
const EMOJIBASE = require('emojibase-data/en/compact.json');
|
2019-05-19 16:23:43 +02:00
|
|
|
|
2017-06-28 12:35:14 +02:00
|
|
|
const fs = require('fs');
|
|
|
|
|
2019-05-19 21:48:18 +02:00
|
|
|
const output = EMOJIBASE.map(
|
|
|
|
(datum) => {
|
2017-06-29 12:29:55 +02:00
|
|
|
const newDatum = {
|
2019-05-19 21:48:18 +02:00
|
|
|
name: datum.annotation,
|
|
|
|
shortname: `:${datum.shortcodes[0]}:`,
|
|
|
|
category: datum.group,
|
|
|
|
emoji_order: datum.order,
|
2017-06-28 12:35:14 +02:00
|
|
|
};
|
2019-05-19 21:48:18 +02:00
|
|
|
if (datum.shortcodes.length > 1) {
|
|
|
|
newDatum.aliases = datum.shortcodes.slice(1).map(s => `:${s}:`);
|
2018-07-24 18:06:45 +02:00
|
|
|
}
|
2019-05-19 21:48:18 +02:00
|
|
|
if (datum.emoticon) {
|
|
|
|
newDatum.aliases_ascii = [ datum.emoticon ];
|
2017-06-29 12:29:55 +02:00
|
|
|
}
|
|
|
|
return newDatum;
|
|
|
|
}
|
2019-05-19 21:48:18 +02:00
|
|
|
);
|
2017-06-28 12:35:14 +02:00
|
|
|
|
2017-06-28 14:44:44 +02:00
|
|
|
// Write to a file in src. Changes should be checked into git. This file is copied by
|
|
|
|
// babel using --copy-files
|
2017-06-28 14:28:48 +02:00
|
|
|
fs.writeFileSync('./src/stripped-emoji.json', JSON.stringify(output));
|