From 043f84a6240fc1656ce824bff5a9b08aba7214e7 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 12 Sep 2019 13:27:46 +0530 Subject: [PATCH] Add script to update FontAwesome Signed-off-by: Harsh Shandilya --- themes/hello-friend-ng/update_fa.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 themes/hello-friend-ng/update_fa.sh diff --git a/themes/hello-friend-ng/update_fa.sh b/themes/hello-friend-ng/update_fa.sh new file mode 100755 index 0000000..e3d8fdf --- /dev/null +++ b/themes/hello-friend-ng/update_fa.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +get_latest_release() { + curl --silent "https://api.github.com/repos/${1:?}/releases/latest" | jq -r .tag_name +} + +update_assets() { + wget https://cdnjs.cloudflare.com/ajax/libs/font-awesome/"${FA_VERSION}"/css/all.min.css -O static/css/fontawesome-"${FA_VERSION}"-all.min.css + + sed -i 's|..\/webfonts|..\/fonts|g' static/css/fontawesome-"${FA_VERSION}"-all.min.css + sed -i "s|fontawesome-${CUR_FA_VERSION}-all.min.css|fontawesome-${FA_VERSION}-all.min.css|" layouts/partials/head.html + + rm -v static/css/fontawesome-"${CUR_FA_VERSION}"-all.min.css 2>/dev/null + + for font in fa-solid-900.woff fa-brands-400.woff fa-solid-900.woff2 fa-brands-400.woff2; do + wget https://cdnjs.cloudflare.com/ajax/libs/font-awesome/"${FA_VERSION}"/webfonts/"${font}" -O static/fonts/"${font}" + done +} + +CUR_FA_VERSION=5.10.2 +FA_VERSION="$(get_latest_release FortAwesome/Font-Awesome)" + +if [ "${CUR_FA_VERSION}" == "${FA_VERSION}" ]; then + echo "FontAwesome is already up-to-date" + exit 0 +else + update_assets +fi