#!/usr/bin/env php setTagline(pht('regenerate Emoji data sheets')); $args->setSynopsis(<<parseStandardArguments(); $args->parse( array( array( 'name' => 'force', 'help' => pht('Force regeneration even if sources have not changed.'), ), )); $root = dirname(phutil_get_library_root('phabricator')); $path = $root.'/webroot/rsrc/externals/emojione/emoji_strategy.json'; $export_path = $root.'/webroot/rsrc/emoji/manifest.json'; if (Filesystem::pathExists($path)) { $json = Filesystem::readFile($path); $emojis = phutil_json_decode($json); $data = array(); foreach ($emojis as $shortname => $emoji) { $unicode = $emoji['unicode']; $codes = explode('-', $unicode); $hex = ''; foreach ($codes as $code) { $hex .= phutil_utf8_encode_codepoint(hexdec($code)); } $data[$shortname] = $hex; } $json = new PhutilJSON(); $data = $json->encodeFormatted($data); Filesystem::writeFile($export_path, $data); echo pht('Done.')."\n"; } else { echo pht('Path %s not exist.', $path)."\n"; }