From 79d3c081ff90288cbd7f21cb8ff4d50064d57c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 13 May 2021 12:55:30 +0200 Subject: [PATCH] MOBILE-3752 lang: Minor fixes on langindex --- scripts/create_langindex.sh | 2 +- scripts/lang_functions.sh | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/create_langindex.sh b/scripts/create_langindex.sh index c17d77c20..0135089ff 100755 --- a/scripts/create_langindex.sh +++ b/scripts/create_langindex.sh @@ -310,7 +310,7 @@ function array_contains { print_title 'Generating language from code...' -gulp lang +npx gulp lang print_title 'Getting languages' diff --git a/scripts/lang_functions.sh b/scripts/lang_functions.sh index d8bcf38ae..cf6e2368a 100755 --- a/scripts/lang_functions.sh +++ b/scripts/lang_functions.sh @@ -10,8 +10,9 @@ DEFAULT_LASTVERSION='4.0' # Checks if AWS is available and configured. function check_aws { - aws --version &> /dev/null AWS_SERVICE=1 + + aws --version &> /dev/null if [ $? -ne 0 ]; then AWS_SERVICE=0 echo 'AWS not installed. Check https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html for more info.' @@ -19,7 +20,7 @@ function check_aws { fi # In order to login to AWS, use credentials file or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY vars. - if [ ! -f ~/.aws/credentials ] && [ [ -z $AWS_ACCESS_KEY_ID ] || [ -z $AWS_SECRET_ACCESS_KEY ] ]; then + if [ ! -f ~/.aws/credentials ] && ([ -z "$AWS_ACCESS_KEY_ID" ] || [ -z "$AWS_SECRET_ACCESS_KEY" ]); then AWS_SERVICE=0 lastversion=$DEFAULT_LASTVERSION echo 'AWS Cannot authenticate. Use aws configure or set the proper env vars.' @@ -63,6 +64,13 @@ function get_last_version { lastversion=$DEFAULT_LASTVERSION } +# Create langfolder +function create_langfolder { + if [ ! -d $LANGPACKSFOLDER ]; then + mkdir $LANGPACKSFOLDER + fi +} + # Get all language list from AWS. function get_all_languages_aws { langsfiles=`aws s3 ls s3://$BUCKET/$lastversion/` @@ -87,6 +95,8 @@ function get_language { get_last_version + create_langfolder + echo "Getting $lang language" pushd $LANGPACKSFOLDER > /dev/null @@ -115,7 +125,7 @@ function get_languages { return fi else - mkdir $LANGPACKSFOLDER + create_langfolder fi