2017-06-28 18:35:14 +08:00
|
|
|
#!/usr/bin/env node
|
2019-05-19 22:23:43 +08:00
|
|
|
|
|
|
|
// This generates src/stripped-emoji.json as used by the EmojiProvider autocomplete
|
|
|
|
// provider.
|
|
|
|
|
2019-05-20 03:48:18 +08:00
|
|
|
const EMOJIBASE = require('emojibase-data/en/compact.json');
|
2019-05-19 22:23:43 +08:00
|
|
|
|
2017-06-28 18:35:14 +08:00
|
|
|
const fs = require('fs');
|
|
|
|
|
2019-05-20 03:48:18 +08:00
|
|
|
const output = EMOJIBASE.map(
|
|
|
|
(datum) => {
|
2017-06-29 18:29:55 +08:00
|
|
|
const newDatum = {
|
2019-05-20 03:48:18 +08:00
|
|
|
name: datum.annotation,
|
|
|
|
shortname: `:${datum.shortcodes[0]}:`,
|
|
|
|
category: datum.group,
|
|
|
|
emoji_order: datum.order,
|
2017-06-28 18:35:14 +08:00
|
|
|
};
|
2019-05-20 03:48:18 +08:00
|
|
|
if (datum.shortcodes.length > 1) {
|
|
|
|
newDatum.aliases = datum.shortcodes.slice(1).map(s => `:${s}:`);
|
2018-07-25 00:06:45 +08:00
|
|
|
}
|
2019-05-20 03:48:18 +08:00
|
|
|
if (datum.emoticon) {
|
|
|
|
newDatum.aliases_ascii = [ datum.emoticon ];
|
2017-06-29 18:29:55 +08:00
|
|
|
}
|
|
|
|
return newDatum;
|
|
|
|
}
|
2019-05-20 03:48:18 +08:00
|
|
|
);
|
2017-06-28 18:35:14 +08:00
|
|
|
|
2017-06-28 20:44:44 +08: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 20:28:48 +08:00
|
|
|
fs.writeFileSync('./src/stripped-emoji.json', JSON.stringify(output));
|