public/Utils/Update-Xray.ps1
using module '..\..\modules\Enums.psm1' using module '..\..\modules\Session.psd1' function Update-Xray(){ [CmdletBinding()] param( [switch] $settings, [switch] $module, [switch] $removeOldVersions, [switch] $listAvailable ) #$session = [Session]::getCurrent() if ($settings){ Write-Host 'Loading current settings...' $settingsFile = [Config]::Load() Write-Debug "Settings: $($settingsFile.autoUpdate)" if ($settingsFile.autoUpdate.settings) { Write-Host 'Downloading new ones...' $newSettings = [Config]::DownloadSettings($settingsFile.autoUpdate.settings) Write-Host 'Successfully downloaded and saved!' } else { Write-Error 'Either there is no settings file, or it is not configured for auto update!' } if ($newSettings) { if ($session){ Write-Host 'Reloading new settings...' $session.config.Reload() Write-Host 'Successfully!' } } } $moduleName = 'SportsbookXray' if ($module){ Update-Module -Name $moduleName } if ($listAvailable){ Get-InstalledModule $moduleName } if ($removeOldVersions){ $latest = Get-InstalledModule $moduleName Get-InstalledModule $moduleName -AllVersions | Where-Object { $_.Version -ne $latest.Version } | Uninstall-Module } } |