mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-21 14:27:49 +07:00
Improve tools support
This commit is contained in:
@ -51,11 +51,15 @@ remove_extension() {
|
||||
add_tool() {
|
||||
url=$1
|
||||
tool=$2
|
||||
if [ ! -e /usr/local/bin/"$tool" ]; then
|
||||
rm -rf /usr/local/bin/"${tool:?}"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
brew install composer >/dev/null 2>&1
|
||||
else
|
||||
if [ ! -e /usr/local/bin/"$tool" ]; then
|
||||
rm -rf /usr/local/bin/"${tool:?}"
|
||||
fi
|
||||
sudo curl -o /usr/local/bin/"$tool" -L "$url" >/dev/null 2>&1
|
||||
sudo chmod a+x /usr/local/bin/"$tool"
|
||||
fi
|
||||
sudo curl -o /usr/local/bin/"$tool" -L "$url" >/dev/null 2>&1
|
||||
sudo chmod a+x /usr/local/bin/"$tool"
|
||||
add_log "$tick" "$tool" "Added"
|
||||
}
|
||||
|
||||
|
@ -89,17 +89,22 @@ Function Add-Tool() {
|
||||
[string]
|
||||
$tool
|
||||
)
|
||||
if (Test-Path $php_dir\$tool) {
|
||||
Remove-Item $php_dir\$tool
|
||||
if($tool -eq "composer") {
|
||||
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
|
||||
} else {
|
||||
if (Test-Path $php_dir\$tool)
|
||||
{
|
||||
Remove-Item $php_dir\$tool
|
||||
}
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool > $null 2>&1
|
||||
$bat_content = @()
|
||||
$bat_content += "@ECHO off"
|
||||
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
||||
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
||||
$bat_content += "php %BIN_TARGET% %*"
|
||||
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
|
||||
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.bat"
|
||||
}
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool > $null 2>&1
|
||||
$bat_content = @()
|
||||
$bat_content += "@ECHO off"
|
||||
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
||||
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
||||
$bat_content += "php %BIN_TARGET% %*"
|
||||
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
|
||||
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.bat"
|
||||
Add-Log $tick $tool "Added"
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user