Skip to content

Commit

Permalink
Fix reading composer package type for older versions
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Jul 20, 2022
1 parent e57ea71 commit 66f2447
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/scripts/tools/add_tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/scripts/tools/add_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 66f2447

Please sign in to comment.