mirror of
https://github.com/twitter/twemoji.git
synced 2024-06-15 03:35:16 +00:00
Correct preview generation script to parse strings via twemoji-parser
This commit is contained in:
parent
77a1b7b8ef
commit
6bdc575e8b
@ -7,18 +7,9 @@
|
|||||||
// dependencies
|
// dependencies
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var { parse } = require('twemoji-parser');
|
||||||
var Utils = require('./utils');
|
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) {
|
function file(which) {
|
||||||
return path.join(__dirname, '..', which);
|
return path.join(__dirname, '..', which);
|
||||||
@ -32,7 +23,7 @@ fs.readdir(file('assets'), function (err, files) {
|
|||||||
var emoji = codepoints.map(function(codepoint) {
|
var emoji = codepoints.map(function(codepoint) {
|
||||||
return Utils.fromCodePoint(codepoint);
|
return Utils.fromCodePoint(codepoint);
|
||||||
}).join('');
|
}).join('');
|
||||||
if (countEmoji(emoji + '\ufe0f') === 1) {
|
if (parse(`${emoji}\ufe0f`).length === 1) {
|
||||||
codepoints.push('fe0f');
|
codepoints.push('fe0f');
|
||||||
}
|
}
|
||||||
return codepoints.map(function (codepoint) {
|
return codepoints.map(function (codepoint) {
|
||||||
|
Loading…
Reference in New Issue
Block a user