diff --git a/CHANGELOG.md b/CHANGELOG.md index 362e805..203aef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.5] - 2022-09-03 +### Added +- Support for forced installation +### Fixed +- Formulae showing up as casks + ## [0.0.4] - 2022-07-02 ### Added - Additional tap metadata retrieval diff --git a/src/Croze.ps1 b/src/Croze.ps1 index a5c8e87..2bebff4 100644 --- a/src/Croze.ps1 +++ b/src/Croze.ps1 @@ -132,6 +132,14 @@ $Commands = @( Description = 'Install a new package with Homebrew' OriginalCommandElements = @('install') OutputHandlers = $PackageInstallHandlers + Parameters = @( + @{ + Name = 'Force' + OriginalName = '--force' + ParameterType = 'switch' + Description = 'Force' + } + ) }, @{ Verb = 'Get' @@ -188,7 +196,8 @@ $Commands = @( # Determine the range of formulae output based on whether we also have cask output $formulaeEndIndex = $( - if ($formulaeStartIndex) { + # Cant use a standard check here, because a valid value could be '0', which would evaluate to $false + if ($formulaeStartIndex -ne $null) { if ($casksStartIndex) { # Stop capturing formulae output two rows before the start of the Cask index $casksStartIndex-2 @@ -200,7 +209,8 @@ $Commands = @( } ) - if ($formulaeStartIndex) { + # Cant use a standard check here, because a valid value could be '0', which would evaluate to $false + if ($formulaeStartIndex -ne $null) { $output[($formulaeStartIndex+1)..$formulaeEndIndex] | ForEach-Object { [PSCustomObject]@{ Name = $_ @@ -209,7 +219,7 @@ $Commands = @( } } - if ($casksStartIndex -ne -1) { + if ($casksStartIndex -ne $null) { $output[($casksStartIndex+1)..($output.Length)] | ForEach-Object { [PSCustomObject]@{ Name = $_ diff --git a/src/Croze.psd1 b/src/Croze.psd1 index e7c7396..a04f9a3 100644 --- a/src/Croze.psd1 +++ b/src/Croze.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'Croze.psm1' - ModuleVersion = '0.0.4' + ModuleVersion = '0.0.5' GUID = '46caec03-e808-4fa2-b464-14677bb60c52' Author = 'Ethan Bergstrom' Copyright = '2022' diff --git a/test/Croze.tests.ps1 b/test/Croze.tests.ps1 index fa48ec0..0ec5e3d 100644 --- a/test/Croze.tests.ps1 +++ b/test/Croze.tests.ps1 @@ -21,7 +21,7 @@ Describe 'basic package search operations' { Describe 'DSC-compliant package installation and uninstallation' { Context 'without additional arguments' { BeforeAll { - $package = 'tmux' + $package = 'ipinfo' } It 'searches for the latest version of a package' { @@ -39,14 +39,14 @@ Describe 'DSC-compliant package installation and uninstallation' { } Context 'with formulae' { BeforeAll { - $package = 'tmux' + $package = 'ipinfo' } It 'searches for the latest version of a package' { Find-HomebrewPackage -Name $package -Formula | Where-Object {$_.Name -eq $package} | Should -HaveCount 1 } It 'silently installs the latest version of a package' { - Install-HomebrewPackage -Name $package -Formula | Where-Object {$_.Name -eq $package} | Should -HaveCount 1 + Install-HomebrewPackage -Name $package -Formula -Force | Where-Object {$_.Name -eq $package} | Should -HaveCount 1 } It 'finds the locally installed package just installed' { Get-HomebrewPackage -Name $package -Formula | Where-Object {$_.Name -eq $package} | Should -HaveCount 1 @@ -67,7 +67,7 @@ Describe 'DSC-compliant package installation and uninstallation' { Find-HomebrewPackage -Name $package -Cask | Where-Object {$_.Name -eq $package} | Should -HaveCount 1 } It 'silently installs the latest version of a package' { - Install-HomebrewPackage -Name $package -Cask | Where-Object {$_.Name -eq $package} | Should -HaveCount 1 + Install-HomebrewPackage -Name $package -Cask -Force | Where-Object {$_.Name -eq $package} | Should -HaveCount 1 } It 'finds the locally installed package just installed' { Get-HomebrewPackage -Name $package -Cask | Where-Object {$_.Name -eq $package} | Should -HaveCount 1 @@ -84,7 +84,7 @@ Describe 'DSC-compliant package installation and uninstallation' { Describe 'pipline-based package installation and uninstallation' { Context 'without additional arguments' { BeforeAll { - $package = 'tmux' + $package = 'ipinfo' } It 'searches for and silently installs the latest version of a package' { @@ -96,11 +96,11 @@ Describe 'pipline-based package installation and uninstallation' { } Context 'with formulae' { BeforeAll { - $package = 'tmux' + $package = 'ipinfo' } It 'searches for and silently installs the latest version of a package' { - Find-HomebrewPackage -Name $package -Formula | Where-Object {$_.Name -eq $package} | Install-HomebrewPackage | Should -HaveCount 1 + Find-HomebrewPackage -Name $package -Formula | Where-Object {$_.Name -eq $package} | Install-HomebrewPackage -Force | Should -HaveCount 1 } It 'finds and silently uninstalls the locally installed package just installed' { {Get-HomebrewPackage -Name $package -Formula | Uninstall-HomebrewPackage} | Should -Not -Throw @@ -112,7 +112,7 @@ Describe 'pipline-based package installation and uninstallation' { } It 'searches for and silently installs the latest version of a package' { - Find-HomebrewPackage -Name $package -Cask | Where-Object {$_.Name -eq $package} | Install-HomebrewPackage | Should -HaveCount 1 + Find-HomebrewPackage -Name $package -Cask | Where-Object {$_.Name -eq $package} | Install-HomebrewPackage -Force | Should -HaveCount 1 } It 'finds and silently uninstalls the locally installed package just installed' { {Get-HomebrewPackage -Name $package -Cask | Uninstall-HomebrewPackage} | Should -Not -Throw @@ -124,7 +124,7 @@ Describe 'pipline-based package installation and uninstallation' { # Describe 'package upgrade' { # Context 'with formulae' { # BeforeAll { -# $package = 'tmux' +# $package = 'ipinfo' # $version = '1.95' # Install-HomebrewPackage -Name $package -Version $version # } @@ -186,7 +186,7 @@ Describe "multi-source support" { Describe 'package metadata retrieval' { Context 'without additional arguments' { BeforeAll { - $package = 'tmux' + $package = 'ipinfo' } It 'returns package metadata' { @@ -195,7 +195,7 @@ Describe 'package metadata retrieval' { } Context 'with formulae' { BeforeAll { - $package = 'tmux' + $package = 'ipinfo' } It 'returns package metadata' {