Fix composer tools setup

This commit is contained in:
Shivam Mathur 2021-02-20 17:54:40 +05:30
parent 739ccacdc4
commit 121cb19a65
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,7 @@ export xdebug3_versions="7.[2-4]|8.[0-9]"
export tool_path_dir="/usr/local/bin"
export composer_bin="$HOME/.composer/vendor/bin"
export composer_json="$HOME/.composer/composer.json"
export composer_lock="$HOME/.composer/composer.lock"
export latest="releases/latest/download"
export github="https://github.com/shivammathur"
export bintray="https://dl.bintray/shivammathur"
@ -191,6 +192,10 @@ configure_composer() {
add_log "$cross" "composer" "Could not download composer"
exit 1
fi
if ! [ -e "$composer_json" ]; then
echo '{}' | tee "$composer_json" >/dev/null 2>&1
sudo chmod 644 "$composer_json"
fi
composer -q config -g process-timeout 0
echo "$composer_bin" >> "$GITHUB_PATH"
if [ -n "$COMPOSER_TOKEN" ]; then
@ -240,7 +245,8 @@ add_composertool() {
fi
fi
(
composer global require "$prefix$release" >/dev/null 2>&1 &&
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
composer global require "$prefix$release" >/dev/null 2>&1
json=$(grep "$prefix$tool" "$composer_json") &&
tool_version=$(get_tool_version 'echo' "$json") &&
add_log "$tick" "$tool" "Added $tool $tool_version"

View File

@ -201,6 +201,9 @@ Function Edit-ComposerConfig() {
Add-Log "$cross" "composer" "Could not download composer"
exit 1;
}
if (-not(Test-Path $composer_json)) {
Set-Content -Path $composer_json -Value "{}"
}
composer -q config -g process-timeout 0
Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
if (Test-Path env:COMPOSER_TOKEN) {
@ -302,7 +305,10 @@ Function Add-Composertool() {
Add-Log $cross $tool "Skipped"
Return
}
composer global require $prefix$release 2>&1 | out-null
if(Test-Path $composer_lock) {
Remove-Item -Path $composer_lock -Force
}
composer global require $prefix$release >$null 2>&1
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
if(Test-Path $composer_bin\composer) {
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
@ -330,6 +336,8 @@ $bin_dir = $php_dir
$bintray = 'https://dl.bintray.com/shivammathur/php'
$github = 'https://github.com'
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
$composer_json = "$env:APPDATA\Composer\composer.json"
$composer_lock = "$env:APPDATA\Composer\composer.lock"
$current_profile = "$env:TEMP\setup-php.ps1"
$ProgressPreference = 'SilentlyContinue'
$nightly_version = '8.[0-9]'