UpdateLibrewolf.ps1


<#PSScriptInfo

.VERSION 0.0.8

.GUID fe19266c-d1c3-451f-a614-ec3fc3b0e17e

.AUTHOR Fabrice Sanga

.COMPANYNAME sangafabrice

.COPYRIGHT © 2022 SangaFabrice. All rights reserved.

.TAGS librewolf update browser

.LICENSEURI https://github.com/sangafabrice/reg-cli/blob/main/LICENSE.md

.PROJECTURI https://github.com/sangafabrice/reg-cli/tree/librewolf

.ICONURI https://rawcdn.githack.com/sangafabrice/reg-cli/a0f8460b42740c8711ff058301d2d38d2abf77b4/icon.png

.EXTERNALMODULEDEPENDENCIES DownloadInfo,RegCli

.REQUIREDSCRIPTS

.EXTERNALSCRIPTDEPENDENCIES

.RELEASENOTES
Remove Select-NonEmptyObject from script.

.PRIVATEDATA

#>


#Requires -Module @{ModuleVersion = '5.0.4'; ModuleName = 'DownloadInfo'}
#Requires -Module @{ModuleVersion = '6.2.2'; ModuleName = 'RegCli'}

[CmdletBinding()]
Param (
    [ValidateNotNullOrEmpty()]
    [ValidateScript({ Test-InstallLocation $_ $PSScriptRoot })]
    [string]
    $InstallLocation = "${Env:ProgramData}\Librewolf",
    [ValidateNotNullOrEmpty()]
    [ValidateScript({ Test-InstallerLocation $_ })]
    [string]
    $SaveTo = $PSScriptRoot
)

& {
    Write-Verbose 'Retrieve install or update information...'
    $UpdateInfo =
        Try { Get-DownloadInfo -From Librewolf }
        Catch { }
    Try {
        $UpdateModule =
            Import-CommonScript chrome-installer |
            Import-Module -PassThru -Force -Verbose:$False
        @{
            UpdateInfo = $UpdateInfo
            NameLocation = "$InstallLocation\librewolf.exe"
            SaveTo = $SaveTo
            SoftwareName = 'Librewolf'
            UseTimestamp = $True
            Checksum = $UpdateInfo.Checksum
            UsePrefix = $True
            Verbose = $VerbosePreference -ine 'SilentlyContinue'
        } | ForEach-Object { Invoke-CommonScript @_ }
    }
    Catch { }
    Finally { $UpdateModule | Remove-Module -Verbose:$False }
}

<#
.SYNOPSIS
    Updates Librewolf browser software.
.DESCRIPTION
    The script installs or updates Librewolf browser on Windows.
.NOTES
    Required: at least Powershell Core 7.
.PARAMETER InstallLocation
    Path to the installation directory.
    It is restricted to file system paths.
    It does not necessary exists.
    It defaults to %ProgramData%\Librewolf.
.PARAMETER SaveTo
    Path to the directory of the downloaded installer.
    It is an existing file system path.
    It defaults to the script directory.
.EXAMPLE
    Get-ChildItem C:\ProgramData\Librewolf -ErrorAction SilentlyContinue

    PS > .\UpdateLibrewolf.ps1 -InstallLocation C:\ProgramData\Librewolf -SaveTo .

    PS > Get-ChildItem C:\ProgramData\Librewolf | Select-Object Name -First 5
    Name
    ----
    $PLUGINSDIR
    browser
    defaults
    distribution
    fonts

    PS > Get-ChildItem | Select-Object Name
    Name
    ----
    librewolf_v104.0-1.exe
    UpdateLibrewolf.ps1

    Install Librewolf browser to 'C:\ProgramData\Librewolf' and save its setup installer to the current directory.
#>