Commit 3e6efcf7 authored by okhin's avatar okhin 🚴

Let's use return instead of exit for errors

parent 1f57401b
Pipeline #2471 failed with stage
in 2 seconds
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment