Improve Write-Error messages

This commit is contained in:
Shivam Mathur 2023-03-14 06:07:46 +05:30
parent 5f422817a1
commit 6461006ceb
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 5 additions and 5 deletions

View File

@ -17,7 +17,7 @@ Function Edit-ComposerConfig() {
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
if ($? -eq $False) {
Add-Log "$cross" "composer" "Could not download composer"
Write-Error "Error" -ErrorAction Stop
Write-Error "Could not download composer" -ErrorAction Stop
}
New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1
if (-not(Test-Path $composer_json)) {

View File

@ -23,7 +23,7 @@ Function Add-Log($mark, $subject, $message) {
} else {
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
if($env:fail_fast -eq 'true') {
Write-Error "Error" -ErrorAction Stop
Write-Error $message -ErrorAction Stop
}
}
}
@ -337,7 +337,7 @@ if ( $env:GITHUB_ACTIONS -eq 'true') {
if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
if($env:RUNNER -eq 'github') {
Add-Log $cross "Runner" "Runner set as github in self-hosted environment"
Write-Error "Error" -ErrorAction Stop
Write-Error "Runner set as github in self-hosted environment" -ErrorAction Stop
}
$bin_dir = 'C:\tools\bin'
$php_dir = "$php_dir$version"
@ -348,7 +348,7 @@ if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
if($version -lt 5.6) {
Add-Log $cross "PHP" "PHP $version is not supported on self-hosted runner"
Start-Sleep 1
Write-Error "Error" -ErrorAction Stop
Write-Error "PHP $version is not supported on self-hosted runner" -ErrorAction Stop
}
if ($null -eq (Get-Module -ListAvailable -Name VcRedist)) {
Install-Module -Name VcRedist -Force
@ -418,7 +418,7 @@ if($env:DEBUG -eq 'true') {
$installed = Get-Php -Path $php_dir
if($installed.MajorMinorVersion -ne $version) {
Add-Log $cross "PHP" "Could not setup PHP $version"
Write-Error "Error" -ErrorAction Stop
Write-Error "Could not setup PHP $version" -ErrorAction Stop
}
if($version -lt "5.5") {
('libeay32.dll', 'ssleay32.dll') | ForEach-Object -Parallel { Get-File -Url "$using:php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $using:php_dir\$_ >$null 2>&1 }