mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Improve composer support
This commit is contained in:
parent
533e0949a8
commit
4ce413f558
@ -107,7 +107,13 @@ add_tool() {
|
||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
||||
if [ "$status_code" = "200" ]; then
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "phive" ]; then
|
||||
if [ "$tool" = "composer" ]; then
|
||||
composer -q global config process-timeout 0
|
||||
echo "::add-path::/Users/$USER/.composer/vendor/bin"
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||
fi
|
||||
elif [ "$tool" = "phive" ]; then
|
||||
add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1
|
||||
add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1
|
||||
add_extension xml "sudo pecl install -f xml" extension >/dev/null 2>&1
|
||||
@ -129,7 +135,6 @@ add_composertool() {
|
||||
prefix=$3
|
||||
(
|
||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||
add_log "$tick" "$tool" "Added"
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
}
|
||||
|
@ -153,6 +153,10 @@ add_tool() {
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
composer -q global config process-timeout 0
|
||||
echo "::add-path::/home/$USER/.composer/vendor/bin"
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||
fi
|
||||
elif [ "$tool" = "cs2pr" ]; then
|
||||
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
||||
elif [ "$tool" = "phive" ]; then
|
||||
@ -173,7 +177,6 @@ add_composertool() {
|
||||
prefix=$3
|
||||
(
|
||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||
add_log "$tick" "$tool" "Added"
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
}
|
||||
|
@ -103,10 +103,7 @@ Function Add-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
|
||||
composer -q global config process-timeout 0
|
||||
} elseif ($tool -eq "symfony") {
|
||||
if ($tool -eq "symfony") {
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
|
||||
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1
|
||||
} else {
|
||||
@ -125,10 +122,16 @@ Function Add-Tool() {
|
||||
Add-Extension curl >$null 2>&1
|
||||
Add-Extension mbstring >$null 2>&1
|
||||
Add-Extension xml >$null 2>&1
|
||||
}
|
||||
if($tool -eq "cs2pr") {
|
||||
} elseif($tool -eq "cs2pr") {
|
||||
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
||||
} elseif($tool -eq "composer") {
|
||||
composer -q global config process-timeout 0
|
||||
Write-Output "::add-path::$env:APPDATA\Composer\vendor\bin"
|
||||
if (Test-Path env:COMPOSER_TOKEN) {
|
||||
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
|
||||
}
|
||||
}
|
||||
|
||||
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
||||
Add-Log $tick $tool "Added"
|
||||
} else {
|
||||
@ -156,8 +159,6 @@ Function Add-Composertool() {
|
||||
)
|
||||
composer -q global require $prefix$release 2>&1 | out-null
|
||||
if($?) {
|
||||
$composer_dir = composer -q global config home | ForEach-Object { $_ -replace "/", "\" }
|
||||
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $composer_dir\vendor\bin\$tool.bat"
|
||||
Add-Log $tick $tool "Added"
|
||||
} else {
|
||||
Add-Log $cross $tool "Could not setup $tool"
|
||||
|
Loading…
Reference in New Issue
Block a user