emoji-convert.sh 931 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. # This script reduces the size and converts the emoji.json file from https://github.com/github/gemoji/blob/master/db/emoji.json
  3. # to be used in the Android app (app/src/main/resources/emoji.json) and the Web UI (server/static/js/emoji.js).
  4. SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
  5. ROOTDIR="$(cd "$(dirname "$0")/.." && pwd)"
  6. if [ -z "$1" ]; then
  7. echo "Syntax: $0 FILE.(js|json)"
  8. echo "Example:"
  9. echo " $0 emoji-converted.json"
  10. echo " $0 $ROOTDIR/server/static/js/emoji.js"
  11. exit 1
  12. fi
  13. if [[ "$1" == *.js ]]; then
  14. echo -n "// This file is generated by scripts/emoji-convert.sh to reduce the size
  15. // Original data source: https://github.com/github/gemoji/blob/master/db/emoji.json
  16. const rawEmojis = " > "$1"
  17. cat "$SCRIPTDIR/emoji.json" | jq -rc 'map({emoji: .emoji,aliases: .aliases})' >> "$1"
  18. else
  19. cat "$SCRIPTDIR/emoji.json" | jq -rc 'map({emoji: .emoji,aliases: .aliases})' > "$1"
  20. fi