From 6bdc575e8b4b8340d7f5b9044261882ebe25f39b Mon Sep 17 00:00:00 2001 From: Nathan Downs Date: Thu, 4 Apr 2019 14:19:49 -0700 Subject: [PATCH] Correct preview generation script to parse strings via twemoji-parser --- 2/scripts/preview | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/2/scripts/preview b/2/scripts/preview index 6eeeb9f5..14b17fe9 100755 --- a/2/scripts/preview +++ b/2/scripts/preview @@ -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) {