Skip to content

Commit

Permalink
DEBUG 1
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed Feb 18, 2024
1 parent 648ae2c commit b8f187e
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions source/Classes/020.BootstrapPSResourceGet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ class BootstrapPSResourceGet : ResourceBase
#>
hidden [System.Collections.Hashtable] GetCurrentState([System.Collections.Hashtable] $keyProperty)
{
Write-Debug -Message "Enter GetCurrentState. Parameters:`n$($keyProperty | Out-String)"
Write-Debug -Message (
'Enter GetCurrentState. Parameters: {0}' -f ($keyProperty | ConvertTo-Json -Compress)
)

Write-Verbose -Message $this.localizedData.EvaluateModule

Expand Down Expand Up @@ -218,7 +220,6 @@ class BootstrapPSResourceGet : ResourceBase
}

Write-Debug -Message 'Exit GetCurrentState'
Write-Verbose -Message 'Exit GetCurrentState' -Verbose

return $currentState
}
Expand All @@ -231,7 +232,9 @@ class BootstrapPSResourceGet : ResourceBase
#>
hidden [void] Modify([System.Collections.Hashtable] $property)
{
Write-Debug -Message "Enter Modify. Parameters:`n$($property | Out-String)"
Write-Debug -Message (
'Enter Modify. Parameters: {0}' -f ($property | ConvertTo-Json -Compress)
)

Write-Verbose -Message $this.localizedData.Bootstrapping

Expand All @@ -255,8 +258,9 @@ class BootstrapPSResourceGet : ResourceBase
#>
hidden [void] AssertProperties([System.Collections.Hashtable] $property)
{
Write-Debug -Message "Enter AssertProperties. Parameters:`n$($property | Out-String)"
Write-Verbose -Message "Enter AssertProperties. Parameters:`n$($property | Out-String)" -Verbose
Write-Debug -Message (
'Enter AssertProperties. Parameters: {0}' -f ($property | ConvertTo-Json -Compress)
)

# The properties ModuleScope and Destination are mutually exclusive.
$assertBoundParameterParameters = @{
Expand Down Expand Up @@ -298,9 +302,20 @@ class BootstrapPSResourceGet : ResourceBase
New-InvalidArgumentException -ArgumentName 'ModuleScope' -Message $errorMessage
}

Write-Verbose -Message "Evaluating if module is present in the scope '$($property.ModuleScope)'" -Verbose
$scopeModulePath = Get-PSModulePath -Scope $property.ModuleScope

if (-not (Test-Path -Path $scopeModulePath))
Write-Verbose -Message (
'[Environment]::GetFolderPath(''MyDocuments''): {0}' -f [Environment]::GetFolderPath('MyDocuments')
)

Write-Verbose -Message (
'$IsCoreCLR: {0}' -f $IsCoreCLR
)

Write-Verbose -Message "The path that was returned for the scope '$($property.ModuleScope)' is '$scopeModulePath'" -Verbose

if ([System.String]::IsNullOrEmpty($scopeModulePath) -or -not (Test-Path -Path $scopeModulePath))
{
$errorMessage = $this.localizedData.ScopePathInvalid -f $property.ModuleScope, $scopeModulePath

Expand All @@ -310,7 +325,7 @@ class BootstrapPSResourceGet : ResourceBase

if ($property.Keys -contains 'Destination')
{
if (-not (Test-Path -Path $property.Destination))
if ([System.String]::IsNullOrEmpty($property.Destination) -or -not (Test-Path -Path $property.Destination))
{
$errorMessage = $this.localizedData.DestinationInvalid -f $property.Destination

Expand Down

0 comments on commit b8f187e

Please sign in to comment.