Преглед изворни кода

build: i18n file download time with millisecond precision

JimMoen пре 2 година
родитељ
комит
e57e19c9f1
1 измењених фајлова са 9 додато и 6 уклоњено
  1. 9 6
      scripts/pre-compile.sh

+ 9 - 6
scripts/pre-compile.sh

@@ -29,17 +29,20 @@ I18N_REPO_BRANCH="v$(./pkg-vsn.sh "${PROFILE_STR}" | tr -d '.' | cut -c 1-2)"
 
 DOWNLOAD_I18N_TRANSLATIONS=${DOWNLOAD_I18N_TRANSLATIONS:-true}
 # download desc (i18n) translations
+beginfmt='\033[1m'
+endfmt='\033[0m'
 if [ "$DOWNLOAD_I18N_TRANSLATIONS" = "true" ]; then
-  echo "downloading i18n translation from emqx/emqx-i18n"
-  start=$(date +%s)
+  echo "Downloading i18n translation from emqx/emqx-i18n..."
+  start=$(date +%s%N)
   curl -L --fail --silent --show-error \
        --output "apps/emqx_dashboard/priv/desc.zh.hocon" \
        "https://raw.githubusercontent.com/emqx/emqx-i18n/${I18N_REPO_BRANCH}/desc.zh.hocon"
-  end=$(date +%s)
-  duration=$(echo "$end $start" | awk '{print $1 - $2}')
-  echo "downloaded i18n translation in $duration seconds, set DOWNLOAD_I18N_TRANSLATIONS=false to skip"
+  end=$(date +%s%N)
+  duration=$(echo "$end $start" | awk '{printf "%.f\n", (($1 - $2)/ 1000000)}')
+  if [ "$duration" -gt 1000 ]; then beginfmt='\033[1;33m'; fi
+  echo -e "Downloaded i18n translation in $duration milliseconds.\nSet ${beginfmt}DOWNLOAD_I18N_TRANSLATIONS=false${endfmt} to skip"
 else
-  echo "skipping to download i18n translation from emqx/emqx-i18n, set DOWNLOAD_I18N_TRANSLATIONS=true to update"
+  echo -e "Skipping to download i18n translation from emqx/emqx-i18n.\nSet ${beginfmt}DOWNLOAD_I18N_TRANSLATIONS=true${endfmt} to update"
 fi
 
 # TODO