Skip to content

Instantly share code, notes, and snippets.

@ziadoz ziadoz/
Last active Feb 4, 2020

What would you like to do?
Check running Composer version is latest using Bash
# Sometimes it's useful to know if Composer actually needs updating or if it was updated, for example for CI builds.
# 1) Check if you're running the latest version of Composer.
# -
# -
LATEST_COMPOSER_VERSION="$(curl --silent "" | jq -r '.[0].name')"
CURRENT_COMPOSER_VERSION="$(composer --version | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')"
echo "Not using latest version"
composer self-update
# 2) Update Composer version, and then do something if an update happened (otherwise nothing is done).
if [[ ! "$(composer self-update 2>&1)" == *"already using composer version"* ]]; then
echo "Upgraded to latest version"
echo "Already running latest version"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.