Skip to content

Commit 883c050

Browse files
authored
fix(): Stop execution with ErrorAction (#32)
Use `-ErrorAction Stop` to terminate execution in the commandlets.
1 parent 7005f5b commit 883c050

5 files changed

+6
-12
lines changed

WebKitDev/Functions/Initialize-VSEnvironment.ps1

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ function Initialize-VSEnvironment {
4545
)
4646

4747
if (!(Test-Path $path)) {
48-
Write-Error ('{0} path not found.' -f $path);
49-
return;
48+
Write-Error ('{0} path not found.' -f $path) -ErrorAction Stop;
5049
}
5150

5251
$toolsetVersion = '';

WebKitDev/Functions/Install-FromPacman.ps1

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ function Install-FromPacman {
3030
)
3131
$bash = Get-Command 'bash' -ErrorAction 'SilentlyContinue';
3232
if ($null -eq $bash) {
33-
Write-Error ('Could not find bash to use to install {0}' -f $name);
34-
return
33+
Write-Error ('Could not find bash to use to install {0}' -f $name) -ErrorAction Stop;
3534
}
3635

3736
# Temp file for output

WebKitDev/Functions/Register-SystemPath.ps1

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ function Register-SystemPath {
2626
)
2727

2828
if (!([System.IO.Path]::IsPathRooted($path))) {
29-
Write-Error 'All system path values need to be absolute';
30-
return;
29+
Write-Error 'All system path values need to be absolute' -ErrorAction Stop;
3130
}
3231

3332
Write-Information -MessageData ('Adding {0} to the system path' -f $path) -InformationAction Continue;

WebKitDev/Functions/Select-VSEnvironment.ps1

+2-4
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ function Select-VSEnvironment {
4545
$version = 'vs2015';
4646
}
4747
else {
48-
Write-Error 'Could not find a compatible Visual Studio instance';
49-
return;
48+
Write-Error 'Could not find a compatible Visual Studio instance' -ErrorAction Stop;
5049
}
5150
}
5251

@@ -69,8 +68,7 @@ function Select-VSEnvironment {
6968
Write-Information -MessageData $vcvars -InformationAction Continue;
7069

7170
if (!(Test-Path $vcvars)) {
72-
Write-Error ('Could not find {0}' -f $vcvars);
73-
return;
71+
Write-Error ('Could not find {0}' -f $vcvars) -ErrorAction Stop;
7472
}
7573

7674
Initialize-VSEnvironment -architecture $architecture -Path $vcvars;

WebKitDev/Functions/Update-XamppPerlLocation.ps1

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function Update-XamppPerlLocation {
2727
$perlExecutable = Join-Path $perlPath (Join-Path 'perl' (Join-Path 'bin' 'perl.exe'));
2828

2929
if (!(Test-Path $perlExecutable)) {
30-
Write-Error ('perl not found at {0}' -f $perlPath);
31-
return;
30+
Write-Error ('perl not found at {0}' -f $perlPath) -ErrorAction Stop;
3231
}
3332

3433
$registryValue = ('{0} -T' -f $perlExecutable);

0 commit comments

Comments
 (0)