Minor changes

pull/35/head
Romain 2022-03-26 16:02:00 +01:00
parent 6827c9afe2
commit b40366abad
4 changed files with 28 additions and 11 deletions

View File

@ -1,6 +1,13 @@
function Get-WAUAvailableVersion{ function Get-WAUAvailableVersion {
#Get Github latest version #Get Github latest version
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest' if ($true -eq $WAUprerelease) {
#Get latest pre-release info
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases'
}
else {
#Get latest stable info
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
}
$Script:WAULatestVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","") $Script:WAULatestVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","")
return [version]$WAULatestVersion return [version]$WAULatestVersion
} }

View File

@ -1,12 +1,23 @@
function Get-WAUUpdateStatus{ function Get-WAUUpdateStatus{
#Get AutoUpdate status
[xml]$UpdateStatus = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue [xml]$UpdateStatus = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
#Check if AutoUpdate is enabled
if ($true -eq $UpdateStatus.app.WAUautoupdate){ if ($true -eq $UpdateStatus.app.WAUautoupdate){
Write-Log "WAU AutoUpdate is Enabled" "Green" Write-Log "WAU AutoUpdate is Enabled" "Green"
return $true $Script:WAUautoupdate = $true
#Check if pre-release versions are enabled
if ($true -eq $UpdateStatus.app.WAUprerelease){
Write-Log "WAU AutoUpdate Pre-release enabled" "Cyan"
$Script:WAUprerelease = $true
}
else{
$Script:WAUprerelease = $false
}
} }
else{ else{
Write-Log "WAU AutoUpdate is Disabled" "Grey" Write-Log "WAU AutoUpdate is Disabled" "Grey"
return $false $Script:WAUautoupdate = $false
} }
} }

View File

@ -25,10 +25,9 @@ function Update-WAU ($VersionToUpdate){
Get-ChildItem -Path $location -Recurse | Unblock-File Get-ChildItem -Path $location -Recurse | Unblock-File
Write-Log "Unzip finished" "Green" Write-Log "Unzip finished" "Green"
$TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path
$TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path if ($TempPath){
if ($TempPath){ Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force
Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force }
}
#Remove update zip file #Remove update zip file
Write-Log "Cleaning temp files" Write-Log "Cleaning temp files"

View File

@ -17,9 +17,9 @@ Get-NotifLocale
#Check network connectivity #Check network connectivity
if (Test-Network){ if (Test-Network){
#Check if WAU update feature is enabled #Check if WAU update feature is enabled
$WAUAutoUpdateEnabled = Get-WAUUpdateStatus Get-WAUUpdateStatus
#If yes then check WAU update #If yes then check WAU update
if ($WAUAutoUpdateEnabled){ if ($true -eq $WAUautoupdate){
#Get Current Version #Get Current Version
$WAUCurrentVersion = Get-WAUCurrentVersion $WAUCurrentVersion = Get-WAUCurrentVersion
#Get Available Version #Get Available Version