mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support to allow composer plugins
This commit is contained in:
parent
050cb8061b
commit
a863ab6d3d
@ -183,7 +183,10 @@ Function Add-ComposertoolHelper() {
|
|||||||
Remove-Item -Path $composer_lock -Force
|
Remove-Item -Path $composer_lock -Force
|
||||||
}
|
}
|
||||||
composer global require $prefix$release $composer_args >$null 2>&1
|
composer global require $prefix$release $composer_args >$null 2>&1
|
||||||
return composer global show $prefix$tool 2>&1 | findstr '^versions'
|
composer global show $prefix$tool 2>&1 | Out-File -FilePath $env:TEMP\composer.log
|
||||||
|
if(findstr '^type *: *composer-plugin' $env:TEMP\composer.log) {
|
||||||
|
composer global config --no-plugins allow-plugins."$prefix$release" true >$null 2>&1
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release))
|
$release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release))
|
||||||
$scoped_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash
|
$scoped_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash
|
||||||
@ -195,8 +198,12 @@ Function Add-ComposertoolHelper() {
|
|||||||
}
|
}
|
||||||
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
|
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
|
||||||
Add-Path $scoped_dir\vendor\bin
|
Add-Path $scoped_dir\vendor\bin
|
||||||
return composer show $prefix$tool -d $unix_scoped_dir 2>&1 | findstr '^versions'
|
composer show $prefix$tool -d $unix_scoped_dir 2>&1 | Out-File -FilePath $env:TEMP\composer.log
|
||||||
|
if(findstr '^type *: *composer-plugin' $env:TEMP\composer.log) {
|
||||||
|
composer config -d $unix_scoped_dir --no-plugins allow-plugins."$prefix$release" true >$null 2>&1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return findstr '^versions' $env:TEMP\composer.log
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup a tool using composer.
|
# Function to setup a tool using composer.
|
||||||
|
@ -144,14 +144,22 @@ add_composertool_helper() {
|
|||||||
if [ "$scope" = "global" ]; then
|
if [ "$scope" = "global" ]; then
|
||||||
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
||||||
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1
|
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1
|
||||||
composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
composer global show "$prefix$tool" 2>&1 | sudo tee /tmp/composer_show.log >/dev/null 2>&1
|
||||||
|
grep -E ^versions /tmp/composer_show.log | sudo tee /tmp/composer.log >/dev/null 2>&1
|
||||||
|
if grep -qE '^type *: *composer-plugin' /tmp/composer_show.log; then
|
||||||
|
composer global config --no-plugins allow-plugins."$prefix$release" true >/dev/null 2>&1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)"
|
scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)"
|
||||||
if ! [ -d "$scoped_dir" ]; then
|
if ! [ -d "$scoped_dir" ]; then
|
||||||
mkdir -p "$scoped_dir"
|
mkdir -p "$scoped_dir"
|
||||||
echo '{}' | tee "$scoped_dir/composer.json" >/dev/null
|
echo '{}' | tee "$scoped_dir/composer.json" >/dev/null
|
||||||
composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1
|
composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1
|
||||||
composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | sudo tee /tmp/composer_show.log >/dev/null 2>&1
|
||||||
|
grep -E ^versions /tmp/composer_show.log | sudo tee /tmp/composer.log >/dev/null 2>&1
|
||||||
|
if grep -qE '^type *: *composer-plugin' /tmp/composer_show.log; then
|
||||||
|
composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$release" true >/dev/null 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
add_path "$scoped_dir"/vendor/bin
|
add_path "$scoped_dir"/vendor/bin
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user