2019-06-26 01:15:00 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
/*! Copyright Twitter Inc. and other contributors. Licensed under MIT *//*
|
|
|
|
https://github.com/twitter/twemoji/blob/gh-pages/LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
// dependencies
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
var { parse } = require('twemoji-parser');
|
|
|
|
var Utils = require('./utils');
|
2019-07-01 23:58:58 +00:00
|
|
|
var { version } = require('../package.json');
|
2019-06-26 01:15:00 +00:00
|
|
|
|
|
|
|
function file(which) {
|
|
|
|
return path.join(__dirname, '..', which);
|
|
|
|
}
|
|
|
|
|
|
|
|
function distFile(...which) {
|
|
|
|
return path.join(__dirname, '..', 'dist', ...which);
|
|
|
|
}
|
|
|
|
|
2019-06-26 01:28:11 +00:00
|
|
|
fs.readdir(file('assets/ai'), function (err, files) {
|
2019-07-01 23:58:58 +00:00
|
|
|
var page = fs.readFileSync(file('src/templates/preview.html'))
|
|
|
|
.toString()
|
|
|
|
.replace(
|
|
|
|
'{{emoji-list}}',
|
|
|
|
'<li>' + files.map(function (filename) {
|
|
|
|
var codepoints = filename.replace('.ai', '').split('-');
|
|
|
|
var emoji = codepoints.map(function(codepoint) {
|
|
|
|
return Utils.fromCodePoint(codepoint);
|
|
|
|
}).join('');
|
|
|
|
if (parse(`${emoji}\ufe0f`).length === 1) {
|
|
|
|
codepoints.push('fe0f');
|
|
|
|
}
|
|
|
|
return codepoints.map(function (codepoint) {
|
|
|
|
return '&#x' + codepoint.toUpperCase() + ';';
|
|
|
|
}).join('');
|
|
|
|
}).join('</li>\n <li>')+ '</li>'
|
|
|
|
)
|
2019-09-25 21:50:07 +00:00
|
|
|
.replace('{{version}}', version)
|
|
|
|
.replace('{{integrityHash}}', Utils.getIntegrityHash(distFile('twemoji.min.js')));
|
2019-06-26 01:15:00 +00:00
|
|
|
fs.writeFileSync(
|
|
|
|
distFile('preview.html'),
|
|
|
|
page.replace(
|
|
|
|
'{{emoji-options}}',
|
|
|
|
JSON.stringify({
|
|
|
|
size: 72
|
|
|
|
})
|
|
|
|
)
|
2019-07-01 23:58:58 +00:00
|
|
|
|
2019-06-26 01:15:00 +00:00
|
|
|
);
|
|
|
|
fs.writeFileSync(
|
|
|
|
distFile('preview-svg.html'),
|
|
|
|
page.replace(
|
|
|
|
'{{emoji-options}}',
|
|
|
|
JSON.stringify({
|
|
|
|
folder: 'svg',
|
|
|
|
ext: '.svg',
|
|
|
|
base: ''
|
|
|
|
})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|