From 3e6efcf7a6db8eb4a2a3e636a7c02cbfee05f0e0 Mon Sep 17 00:00:00 2001 From: Okhin Date: Mon, 11 Mar 2019 18:25:24 +0100 Subject: [PATCH] Let's use return instead of exit for errors --- scripts/install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 8f5bbac..a804a00 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -6,13 +6,13 @@ # Si une variable $DEBUG existe dans l'environnement, ce script considère que l'on est # en preprod. # -[[ -z ${WPCLI_PATH+x} ]] && echo "\$WPCLI_PATH is undefined." && exit 1 -[[ ! -f ${WPCLI_PATH} ]] && echo "\$WPCLI_PATH does not exist ($WPCLI_PATH)" && exit 1 +[[ -z ${WPCLI_PATH+x} ]] && echo "\$WPCLI_PATH is undefined." && return 1 +[[ ! -f ${WPCLI_PATH} ]] && echo "\$WPCLI_PATH does not exist ($WPCLI_PATH)" && return 1 -[[ -z ${WP_PATH+x} ]] && echo "\$WP_PATH is undefined." && exit 1 -[[ ! -d ${WP_PATH} ]] && echo "\$WP_PATH is not a directory or does not exist ($WP_PATH)" && exit 1 +[[ -z ${WP_PATH+x} ]] && echo "\$WP_PATH is undefined." && return 1 +[[ ! -d ${WP_PATH} ]] && echo "\$WP_PATH is not a directory or does not exist ($WP_PATH)" && return 1 -[[ -z ${1+x} ]] && echo "You need to pass a site.yml file as first and only argument of this script" && exit 1 +[[ -z ${1+x} ]] && echo "You need to pass a site.yml file as first and only argument of this script" && return 1 [[ ! -f $1 ]] && echo "$1: does not exist" WPCLI="php ${WPCLI_PATH} --path=${WP_PATH}" @@ -23,15 +23,15 @@ source $1 [[ -z ${PREPROD+x} ]] && URL="https://${THEME}.grange.dev.lqdn.fr" # Au cas où, on vérifie que wordpress est bien installé. -$WPCLI core is-installed || echo "Sorry, wordpress isn't installed in $WP_PATH." || exit 1 +$WPCLI core is-installed || echo "Sorry, wordpress isn't installed in $WP_PATH." || return 1 # Créons un site -SITE_ID=$WPCLI site create --slug=${THEME} --title=${TITLE} --description=${DESCRIPTION} ${PREPROD:+"--private=true"} --porcelain || echo "Oops, something bas happened." || exit 1 +$WPCLI site create --slug=${THEME} --title=${TITLE} --description=${DESCRIPTION} ${PREPROD:+"--private=true"} --porcelain || echo "Oops, something bas happened." || return 1 # Créons un thème. On crée un .zip à partir de ce qu'il y a dans le répertoire parent # en n'excluant certains fichiers (le répertoire scripts notamment, et les fichiers commençant par .git) zip ${THEME}.zip -r * -x .git\* -x scripts -$WPCLI theme install ./${THEME}.zip ${PREPROD:+"--force"} --activate --url=${URL} || echo "Oops install of ${THEME}.zip went bad" || exit 1 +$WPCLI theme install ./${THEME}.zip ${PREPROD:+"--force"} --activate --url=${URL} || echo "Oops install of ${THEME}.zip went bad" || return 1 # Activation des plugins for $PLUGIN in $PLUGINS -- GitLab