Skip to content

Commit

Permalink
Attempt to upgrade on dependency error
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Mar 24, 2024
1 parent eb73c01 commit 719332a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/scripts/darwin.sh
Expand Up @@ -142,12 +142,17 @@ update_dependencies() {

# Function to fix dependencies on install PHP version.
fix_dependencies() {
local existing_version=$1
broken_deps_paths=$(php -v 2>&1 | grep -Eo '/opt/[a-zA-Z0-9@\.]+')
if [ "x$broken_deps_paths" != "x" ]; then
update_dependencies
IFS=" " read -r -a formulae <<< "$(echo "$broken_deps_paths" | tr '\n' ' ' | sed 's|/opt/||g' 2>&1)$php_formula"
brew reinstall "${formulae[@]}"
brew link --force --overwrite "$php_formula" || true
broken_deps_paths=$(php -v 2>&1 | grep -Eo '/opt/[a-zA-Z0-9@\.]+')
if [ "x$broken_deps_paths" != "x" ]; then
add_php "upgrade" "$existing_version" >/dev/null 2>&1
fi
fi
}

Expand Down Expand Up @@ -233,7 +238,7 @@ setup_php() {
status="Updated to"
else
status="Found"
fix_dependencies >/dev/null 2>&1
fix_dependencies "$existing_version" >/dev/null 2>&1
fi
php_config="$(command -v php-config)"
ext_dir="$(grep 'extension_dir=' "$php_config" | cut -d "'" -f 2)"
Expand Down

0 comments on commit 719332a

Please sign in to comment.