Skip to content

Commit

Permalink
Fix composer tools setup
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Feb 20, 2021
1 parent 739ccac commit 121cb19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 9 additions & 1 deletion src/scripts/win32.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]'
Expand Down

0 comments on commit 121cb19

Please sign in to comment.