From 5f422817a1c142632541535cd6e75a173d61d12f Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Tue, 14 Mar 2023 06:02:04 +0530 Subject: [PATCH] Use Write-Error with ErrorAction as Stop instead of exit --- src/scripts/tools/add_tools.ps1 | 2 +- src/scripts/win32.ps1 | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scripts/tools/add_tools.ps1 b/src/scripts/tools/add_tools.ps1 index 364410da..49730f43 100644 --- a/src/scripts/tools/add_tools.ps1 +++ b/src/scripts/tools/add_tools.ps1 @@ -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" - exit 1; + Write-Error "Error" -ErrorAction Stop } New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1 if (-not(Test-Path $composer_json)) { diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index bd5d4331..f4a6bed1 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -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') { - exit 1; + Write-Error "Error" -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" - exit 1 + Write-Error "Error" -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 - exit 1 + Write-Error "Error" -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" - exit 1 + Write-Error "Error" -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 }