Skip to content

Commit bdd5a15

Browse files
committed
early exit
1 parent 5f10195 commit bdd5a15

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

src/powershell-extended/Install-NerdFont.ps1

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -782,16 +782,8 @@ begin {
782782
do {
783783
$Name = Show-Menu -Options $allNerdFonts
784784
if ($Name -eq 'quit') {
785-
$Name = $null
786785
Write-Host "Selection process canceled."
787-
if ($null -eq $MyInvocation.InvocationName -or $MyInvocation.InvocationName -eq '&') {
788-
# Running as a script block
789-
return
790-
}
791-
else {
792-
# Running as a standalone script
793-
exit
794-
}
786+
return
795787
}
796788
} while (-not $Name)
797789

@@ -806,14 +798,7 @@ begin {
806798
}
807799
}
808800
else {
809-
if ($null -eq $MyInvocation.InvocationName -or $MyInvocation.InvocationName -eq '&') {
810-
# Running as a script block
811-
return
812-
}
813-
else {
814-
# Running as a standalone script
815-
exit
816-
}
801+
return
817802
}
818803
}
819804
elseif ($PSBoundParameters.Name) {
@@ -829,14 +814,7 @@ begin {
829814

830815
if ($nerdFontsToInstall.Count -eq 0) {
831816
Write-Error "No matching fonts found."
832-
if ($null -eq $MyInvocation.InvocationName -or $MyInvocation.InvocationName -eq '&') {
833-
# Running as a script block
834-
return
835-
}
836-
else {
837-
# Running as a standalone script
838-
exit
839-
}
817+
return
840818
}
841819

842820
# Fetch releases for each unique URL
@@ -906,6 +884,8 @@ begin {
906884
}
907885

908886
process {
887+
if ($nerdFontsToInstall.Count -eq 0) { return }
888+
909889
try {
910890
Write-Verbose "Installing $($nerdFontsToInstall.Count) Nerd Fonts to $Scope scope."
911891

@@ -1154,6 +1134,8 @@ process {
11541134
}
11551135

11561136
end {
1137+
if ($nerdFontsToInstall.Count -eq 0) { return }
1138+
11571139
if ([System.IO.Directory]::Exists($tempPath)) {
11581140
Write-Verbose "Removing temporary directory: $tempPath"
11591141
[System.IO.Directory]::Delete($tempPath, $true)

0 commit comments

Comments
 (0)