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

Use the regex from twemoji-parser in our generated code

This commit is contained in:
Nathan Downs 2019-04-03 17:39:04 -07:00
parent fa2e812985
commit f953ea2406
2 changed files with 4 additions and 5 deletions

View File

@ -39,14 +39,12 @@ require('child_process').spawn(
'--verbose',
file('twemoji.js'),
'-o',
file('twemoji.tmp.js')
file('twemoji.min.js')
]
).on('close', function () {
fs.writeFileSync(
file('twemoji.min.js'),
'/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */\n' +
fs.readFileSync(file('twemoji.tmp.js'))
fs.readFileSync(file('twemoji.min.js')) + '\n'
);
fs.unlink(file('twemoji.tmp.js'));
// gzip -c twemoji.min.js | wc -c
});

View File

@ -9,6 +9,7 @@ var fs = require('fs');
var http = require('http');
var path = require('path');
var Utils = require('./utils');
var regex = require('twemoji-parser/dist/lib/regex').default;
function file(which) {
return path.join(__dirname, '../..', which);
@ -1032,7 +1033,7 @@ function createTwemoji(re) {
// drop current indentation
.replace(/^ /gm, '')
// add the RegExp in the right place
.replace('re = /twemoji/', `re = /${fs.readFileSync(path.join(__dirname, 'regex')).toString().trim()}/g`)
.replace('re = /twemoji/', `re = ${regex.toString()}`)
// add the full license
.replace('/*! (C) Twitter Inc. */',
'/*! (C) Twitter Inc. *//*\n' +