Skip to content

Commit d146ade

Browse files
committed
Do net check for function existence
1 parent 6608604 commit d146ade

File tree

1 file changed

+6
-65
lines changed

1 file changed

+6
-65
lines changed

Sources/Winget-AutoUpdate/Winget-Install.ps1

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -68,71 +68,12 @@ else {
6868
$scriptItem.DirectoryName
6969
}
7070

71-
$FilePath = "$realPath\functions\Write-ToLog.ps1"
72-
if (Test-Path $FilePath) {
73-
. $FilePath
74-
}
75-
else {
76-
if (Get-Command -Name "Write-ToLog" -ErrorAction SilentlyContinue) {
77-
Write-ToLog "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." "Red"
78-
}
79-
else {
80-
Write-Host "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." -ForegroundColor Red
81-
}
82-
Exit 1
83-
}
84-
$FilePath = "$realPath\functions\Install-Prerequisites.ps1"
85-
if (Test-Path $FilePath) {
86-
. $FilePath
87-
}
88-
else {
89-
if (Get-Command -Name "Write-ToLog" -ErrorAction SilentlyContinue) {
90-
Write-ToLog "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." "Red"
91-
}
92-
else {
93-
Write-Host "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." -ForegroundColor Red
94-
}
95-
Exit 1
96-
}
97-
$FilePath = "$realPath\functions\Add-ScopeMachine.ps1"
98-
if (Test-Path $FilePath) {
99-
. $FilePath
100-
}
101-
else {
102-
if (Get-Command -Name "Write-ToLog" -ErrorAction SilentlyContinue) {
103-
Write-ToLog "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." "Red"
104-
}
105-
else {
106-
Write-Host "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." -ForegroundColor Red
107-
}
108-
Exit 1
109-
}
110-
$FilePath = "$realPath\functions\Get-WingetCmd.ps1"
111-
if (Test-Path $FilePath) {
112-
. $FilePath
113-
}
114-
else {
115-
if (Get-Command -Name "Write-ToLog" -ErrorAction SilentlyContinue) {
116-
Write-ToLog "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." "Red"
117-
}
118-
else {
119-
Write-Host "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." -ForegroundColor Red
120-
}
121-
Exit 1
122-
}
123-
$FilePath = "$realPath\functions\Confirm-Installation.ps1"
124-
if (Test-Path $FilePath) {
125-
. $FilePath
126-
}
127-
else {
128-
if (Get-Command -Name "Write-ToLog" -ErrorAction SilentlyContinue) {
129-
Write-ToLog "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." "Red"
130-
}
131-
else {
132-
Write-Host "Error: Cannot find required file $FilePath - Unable to import function. Aborting run." -ForegroundColor Red
133-
}
134-
Exit 1
135-
}
71+
. "$realPath\functions\Install-Prerequisites.ps1"
72+
. "$realPath\functions\Update-StoreApps.ps1" #Used by Install-Prerequisites
73+
. "$realPath\functions\Add-ScopeMachine.ps1"
74+
. "$realPath\functions\Get-WingetCmd.ps1"
75+
. "$realPath\functions\Write-ToLog.ps1"
76+
. "$realPath\functions\Confirm-Installation.ps1"
13677

13778
#Check if App exists in Winget Repository
13879
function Confirm-Exist ($AppID) {

0 commit comments

Comments
 (0)