Skip to content

Commit

Permalink
build: stable output for emoji data
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed May 1, 2022
1 parent b361fdc commit 0b7138b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/utils/emojiShortcodes.js

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions tasks/emoji.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ for (const [hex, shortcode] of Object.entries(joypixelShortcodes)) {

console.log('generating', Object.keys(shortcodes).length, 'emoji...');

const shortcodeHashes = {};
await fs.rm(outputDir, { force: true, recursive: true });
await fs.mkdir(outputDir, { recursive: true });
await pMap(Object.entries(shortcodes), async ([shortcode, filename]) => {
const bytes = await fs.readFile(new URL(filename, twemojiDir));
const hash = crypto.createHash('sha1').update(bytes).digest('hex').slice(0, 7);
shortcodeHashes[shortcode] = `${hash}.svg`;
await fs.writeFile(new URL(`${hash}.svg`, outputDir), bytes);
});
const shortcodeHashes = Object.fromEntries(
await pMap(Object.entries(shortcodes), async ([shortcode, filename]) => {
const bytes = await fs.readFile(new URL(filename, twemojiDir));
const hash = crypto.createHash('sha1').update(bytes).digest('hex').slice(0, 7);
const outName = `${hash}.svg`;
await fs.writeFile(new URL(outName, outputDir), bytes);
return [shortcode, outName];
}),
);
await fs.writeFile(new URL('../src/utils/emojiShortcodes.js', import.meta.url), `
// GENERATED FILE: run \`npm run emoji\`
/* eslint-disable */
Expand Down

0 comments on commit 0b7138b

Please sign in to comment.