From 044ae9d175b39e43ba456dff35e211d96effe622 Mon Sep 17 00:00:00 2001 From: Thomas Arrow Date: Tue, 16 Dec 2025 16:20:07 +0000 Subject: [PATCH] sync.sh: update or install but not both We should probably either update or install (using the lock file) if it is present but not try to install and then update. In the case that an update is needed because of a change to either composer.json or to a composer.json included from composer-merge-plugin we don't want to try an install only to have it fail (and then the script exit early) This commit therefore also renames the bash ENV var to be clearer --- sync.sh | 6 +++--- sync/04-docker-composer.sh | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sync.sh b/sync.sh index f14a5bc95..2c69b732e 100755 --- a/sync.sh +++ b/sync.sh @@ -23,13 +23,13 @@ Help() } # Set variable defaults -ALSO_COMPOSER_UPDATE="" +COMPOSER_UPDATE="" # Get the options while getopts ":uh" option; do case $option in u) - ALSO_COMPOSER_UPDATE="1";; + COMPOSER_UPDATE="1";; h) # display Help Help exit;; @@ -37,7 +37,7 @@ while getopts ":uh" option; do done # Export vars for other scripts -export ALSO_COMPOSER_UPDATE=${ALSO_COMPOSER_UPDATE} +export COMPOSER_UPDATE=${COMPOSER_UPDATE} # includes filenames beginning with a '.' in the results of filename expansion (/*) shopt -s dotglob diff --git a/sync/04-docker-composer.sh b/sync/04-docker-composer.sh index 956e7cb58..b5dcc0d27 100755 --- a/sync/04-docker-composer.sh +++ b/sync/04-docker-composer.sh @@ -39,16 +39,16 @@ cp -r "$COMPOSER_WORK_DIR"/vendor "$PWD"/dist # composer install COMPOSER_WORK_DIR="$PWD"/dist -echo "Performing composer install with composer-merge plugin" -composer_in_docker install --no-dev --no-progress --optimize-autoloader -# composer update (When ALSO_COMPOSER_UPDATE = 1) -if [ "${ALSO_COMPOSER_UPDATE}" = "1" ]; then - echo "Performing composer update" + +# composer update (When COMPOSER_UPDATE = 1) +if [ "${COMPOSER_UPDATE}" = "1" ]; then + echo "Performing composer update with composer-merge plugin" composer_in_docker update --no-dev --no-progress --optimize-autoloader cp dist/composer.lock dist-persist/ else - echo "SKIPPING: composer update (As you didn't request it)" + echo "Performing composer install with composer-merge plugin" + composer_in_docker install --no-dev --no-progress --optimize-autoloader fi; # Sometimes composer git clones things rather than using zips.