1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-10-02 21:02:03 +00:00

Correct preview generation script to parse strings via twemoji-parser

This commit is contained in:
Nathan Downs 2019-04-04 14:19:49 -07:00
parent 77a1b7b8ef
commit 6bdc575e8b

View File

@ -7,18 +7,9 @@
// dependencies
var fs = require('fs');
var path = require('path');
var { parse } = require('twemoji-parser');
var Utils = require('./utils');
var regex = new RegExp(fs.readFileSync(file('scripts/regex')).toString(), 'g');
function countEmoji(emoji) {
var count = 0;
regex.lastIndex = 0;
while (regex.exec(emoji)) {
count++;
}
return count;
}
function file(which) {
return path.join(__dirname, '..', which);
@ -32,7 +23,7 @@ fs.readdir(file('assets'), function (err, files) {
var emoji = codepoints.map(function(codepoint) {
return Utils.fromCodePoint(codepoint);
}).join('');
if (countEmoji(emoji + '\ufe0f') === 1) {
if (parse(`${emoji}\ufe0f`).length === 1) {
codepoints.push('fe0f');
}
return codepoints.map(function (codepoint) {