Skip to content

Commit

Permalink
better error handling for testing fixture version
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence committed Oct 3, 2023
1 parent c25ff73 commit 0f405ab
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion bin/validate-fixture-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,24 @@ main(){
FIXTURE_VERSION=$(terminus wp "${TERMINUS_SITE}.dev" -- core version)
echo "Fixture Version: ${FIXTURE_VERSION}"

if ! php -r "exit(version_compare('${TESTED_UP_TO}', '${FIXTURE_VERSION}'));"; then
php -r "exit(version_compare('${TESTED_UP_TO}', '${FIXTURE_VERSION}'));"
exit_code=$?

if [ $exit_code -eq 255 ]; then
echo "An error occurred during version comparison."
exit 1
elif [ $exit_code -eq 1 ]; then
echo "${FIXTURE_VERSION} is less than ${TESTED_UP_TO}"
echo "Please update ${TERMINUS_SITE} to at least WordPress ${TESTED_UP_TO}"
exit 1
elif [ $exit_code -eq 0 ]; then
echo "${FIXTURE_VERSION} is equal to ${TESTED_UP_TO}"
echo "No action required."
exit 0
else
echo "${FIXTURE_VERSION} is greater than ${TESTED_UP_TO}"
echo "You should update the 'Tested up to' in your plugin's readme.txt"
exit 1
fi
}

Expand Down

0 comments on commit 0f405ab

Please sign in to comment.