Skip to content

Commit

Permalink
fixed #31 for all calls (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelcolas committed Apr 2, 2023
1 parent 13e6504 commit d8ffc93
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Modified project with new Sampler template.
- Invoking choco commands now always add `--no-progress` & `--limit-output`.
- Limiting Get-Command choco to the first result as per [#69](https://github.com/chocolatey-community/Chocolatey/issues/69).
- Limiting Get-Command choco to the first result as per [#69](https://github.com/chocolatey-community/Chocolatey/issues/69) on all calls.
- Changed `ChocolateySoftware` to be class-based DSC Resource.
- Changed `ChocolateyPackage` to be class-based DSC Resource.
- Changed `ChocolateySource` to be a class-based DSC Resource.
Expand Down
2 changes: 1 addition & 1 deletion source/Classes/002.ChocolateyPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class ChocolateyPackage
'BelowExpectedVersion$'
{
Write-Debug -Message ('Upgrading package ''{0}'' to version ''{1}''.' -f $this.Name, $this.Version)
$chocoCommand = Get-Command -Name 'Update-ChocolateyPackage' -Module 'Chocolatey'
$chocoCommand = Get-Command -Name 'Update-ChocolateyPackage' -Module 'Chocolatey'
}

'ShouldBeInstalled$'
Expand Down
2 changes: 1 addition & 1 deletion source/Classes/003.ChocolateySoftware.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ChocolateySoftware
[ChocolateySoftware] Get()
{
$currentState = [ChocolateySoftware]::new()
$chocoExe = Get-Command -Name 'choco.exe' -ErrorAction 'Ignore'
$chocoExe = @(Get-Command -Name 'choco.exe' -ErrorAction 'Ignore')[0]

if ($null -eq $chocoExe)
{
Expand Down
2 changes: 1 addition & 1 deletion source/public/Add-ChocolateyPin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Add-ChocolateyPin

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Disable-ChocolateyFeature.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Disable-ChocolateyFeature

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Disable-ChocolateySource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Disable-ChocolateySource

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Enable-ChocolateyFeature.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Enable-ChocolateyFeature

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Enable-ChocolateySource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Enable-ChocolateySource

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Get-ChocolateyFeature.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Get-ChocolateyFeature
)
begin
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Get-ChocolateyPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function Get-ChocolateyPackage

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue'))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Get-ChocolateyPin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Get-ChocolateyPin

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Get-ChocolateySetting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Get-ChocolateySetting
)
begin
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Get-ChocolateySource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Get-ChocolateySource
)
begin
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Get-ChocolateyVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Get-ChocolateyVersion
param (
)

if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Register-ChocolateySource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function Register-ChocolateySource

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Remove-ChocolateyPin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Remove-ChocolateyPin

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Set-ChocolateySetting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Set-ChocolateySetting

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/Test-ChocolateyInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Test-ChocolateyInstall
$InstallDir = (Resolve-Path $InstallDir -ErrorAction Stop).Path
}

if ($chocoCmd = get-command choco.exe -CommandType Application -ErrorAction SilentlyContinue)
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
if (
!$InstallDir -or
Expand Down
4 changes: 2 additions & 2 deletions source/public/Uninstall-Chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ function Uninstall-Chocolatey
if (-not $InstallDir)
{
Write-Debug -Message "Attempting to find the choco.exe command."
$chocoCmd = Get-Command -Name 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue'
$chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]
#Install dir is where choco.exe is found minus \bin subfolder
if (-not ($chocoCmd -and ($chocoBin = Split-Path -Parent $chocoCmd.Path -ErrorAction SilentlyContinue)))
{
Write-Warning "Could not find Chocolatey Software Install Folder."
Write-Warning -Message "Could not find Chocolatey Software Install Folder."
return
}
else
Expand Down
2 changes: 1 addition & 1 deletion source/public/Unregister-ChocolateySource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Unregister-ChocolateySource

process
{
if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue))
if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]))
{
throw "Chocolatey Software not found."
}
Expand Down

0 comments on commit d8ffc93

Please sign in to comment.