Skip to content

Commit

Permalink
Update version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickenfuego committed Jul 15, 2022
1 parent c26e11c commit b93005f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion modules/FFTools/FFTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ ___________ .__ __ .__ ______________________
'@

# Current script release version
[version]$release = '2.0.2'
[version]$release = '2.0.3'


#### End module variables ####
Expand Down
18 changes: 12 additions & 6 deletions scripts/VerifyVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
function Get-ReleaseVersion ([string]$Repository) {
$repo = switch ($Repository) {
'PowerShell' { 'PowerShell/PowerShell' }
'Pwsh' { 'PowerShell/PowerShell' }
'FFEncoder' { 'patrickenfuego/FFEncoder' }
'Pwsh' { 'PowerShell/PowerShell' }
'Posh' { 'PowerShell/PowerShell' }
'FFEncoder' { 'patrickenfuego/FFEncoder' }
}

$uri = "https://api.github.com/repos/$repo/releases"
Expand Down Expand Up @@ -76,13 +77,16 @@ function Confirm-PoshVersion {

<#
.SYNOPSIS
Check for updates to FFEncoder and pull the latest
Check for updates to FFEncoder and pull the latest release
.DESCRIPTION
Function to compare the internal release of FFEncoder against the release version in GitHub.
If a newer version is available, the user is prompted to clone the latest repo and exit the
current PowerShell session
.PARAMETER CurrentRelease
Current version of script. Pulled from the module manifest
.NOTES
Pulling the latest release will not overwrite the current directory - it appends the '-latest'
tag to the directory name to prevent conflicts
#>
function Update-FFEncoder ([version]$CurrentRelease, [switch]$Verbose) {
if ($Verbose) { $VerbosePreference = 'Continue' }
Expand All @@ -96,8 +100,9 @@ function Update-FFEncoder ([version]$CurrentRelease, [switch]$Verbose) {
}

Write-Host ""
$yn = $psReq ? ("($($PSStyle.Foreground.BrightGreen+$PSStyle.Bold)Y$($PSStyle.Reset) / $($PSStyle.Foreground.BrightRed+$PSStyle.Bold)N$($PSStyle.Reset))") :
'(Y / N)'
$yn = $psReq ?
("($($PSStyle.Foreground.BrightGreen+$PSStyle.Bold)Y$($PSStyle.Reset) / $($PSStyle.Foreground.BrightRed+$PSStyle.Bold)N$($PSStyle.Reset))") :
'(Y / N)'

$params = @{
Prompt = "There is an update available for FFEncoder. Would you like to pull the latest release? $yn`: "
Expand All @@ -118,14 +123,15 @@ function Update-FFEncoder ([version]$CurrentRelease, [switch]$Verbose) {
Write-Host "The updated repository will be cloned with the suffix '-latest' inside the parent directory" @progressColors

if (Get-Command 'git') {
Push-Location (Get-Location).Path && Push-Location ((Get-Item (Get-Location)).Parent).FullName
$repoPath = ([System.IO.Path]::Join((Get-Location).Path, 'FFEncoder-latest')).ToString()

if ([System.IO.Directory]::Exists($repoPath)) {
Write-Host "Repository directory already exists. Rename or delete the old one before pulling the update" @warnColors
Pop-Location
return
}

Push-Location (Get-Location).Path && Push-Location ((Get-Item (Get-Location)).Parent).FullName
# Clone the repo and save it with the -latest suffix in the same parent directory
git clone https://github.com/patrickenfuego/FFEncoder.git $repoPath
Pop-Location
Expand Down

0 comments on commit b93005f

Please sign in to comment.