1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-11-17 05:12:37 +00:00
twemoji/2/scripts/preview

54 lines
1.4 KiB
Plaintext
Raw Normal View History

2016-02-29 13:36:17 +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');
2016-02-29 13:36:17 +00:00
2016-02-29 13:36:17 +00:00
function file(which) {
return path.join(__dirname, '..', which);
}
fs.readdir(file('assets'), function (err, files) {
var page = fs.readFileSync(file('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() + ';';
2016-02-29 13:36:17 +00:00
}).join('');
}).join('</li>\n <li>')+ '</li>'
);
fs.writeFileSync(
file('test/preview.html'),
page.replace(
'{{emoji-options}}',
JSON.stringify({
size: 72
})
)
);
fs.writeFileSync(
file('test/preview-svg.html'),
page.replace(
'{{emoji-options}}',
JSON.stringify({
2016-03-01 08:33:00 +00:00
folder: '../svg',
2016-02-29 13:36:17 +00:00
ext: '.svg',
base: ''
})
)
);
});