From 66f24470dcf2decb70ec50b2c0e25cbdb06997ab Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 20 Jul 2022 19:24:19 +0530 Subject: [PATCH] Fix reading composer package type for older versions --- src/scripts/tools/add_tools.ps1 | 6 +++++- src/scripts/tools/add_tools.sh | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/scripts/tools/add_tools.ps1 b/src/scripts/tools/add_tools.ps1 index 62cc38a6..f4f978f0 100644 --- a/src/scripts/tools/add_tools.ps1 +++ b/src/scripts/tools/add_tools.ps1 @@ -201,11 +201,15 @@ Function Add-ComposertoolHelper() { [string] $composer_args ) + $tool_version = $release.split(':')[1] + if($NULL -eq $tool_version) { + $tool_version = '*' + } if($scope -eq 'global') { if(Test-Path $composer_lock) { Remove-Item -Path $composer_lock -Force } - if((composer global show $prefix$tool -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) { + if((composer global show $prefix$tool $tool_version -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) { composer global config --no-plugins allow-plugins."$prefix$tool" true >$null 2>&1 } composer global require $prefix$release $composer_args >$null 2>&1 diff --git a/src/scripts/tools/add_tools.sh b/src/scripts/tools/add_tools.sh index 0568fda3..cdf56506 100644 --- a/src/scripts/tools/add_tools.sh +++ b/src/scripts/tools/add_tools.sh @@ -160,9 +160,10 @@ add_composertool_helper() { scope=$4 composer_args=$5 enable_extensions curl mbstring openssl + tool_version=${release##*:}; [ "$tool_version" = "$tool" ] && tool_version="*" if [ "$scope" = "global" ]; then sudo rm -f "$composer_lock" >/dev/null 2>&1 || true - if composer global show "$prefix$tool" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then + if composer global show "$prefix$tool" "$tool_version" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then composer global config --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1 fi composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1 @@ -172,7 +173,7 @@ add_composertool_helper() { if ! [ -d "$scoped_dir" ]; then mkdir -p "$scoped_dir" echo '{}' | tee "$scoped_dir/composer.json" >/dev/null - if composer show "$prefix$tool" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then + if composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1 fi composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1