Skip to content

Commit

Permalink
Get-ClassResourceProperty - Check for prefixed and non-prefixed cla…
Browse files Browse the repository at this point in the history
…ss names (#152)
  • Loading branch information
dan-hughes authored Aug 13, 2024
1 parent c37ad91 commit 5bd7ef8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- `Get-ClassResourceProperty`
- Check for a prefixed and non-prefixed class names [issue #132](https://github.com/dsccommunity/DscResource.DocGenerator/issues/132).
- `azure-pipelines`
- Pin gitversion to V5.

## [0.12.4] - 2024-06-03

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ stages:
vmImage: 'ubuntu-latest'
steps:
- pwsh: |
dotnet tool install --global GitVersion.Tool
dotnet tool install --global GitVersion.Tool --version 5.*
$gitVersionObject = dotnet-gitversion | ConvertFrom-Json
$gitVersionObject.PSObject.Properties.ForEach{
Write-Host -Object "Setting Task Variable '$($_.Name)' with value '$($_.Value)'."
Expand Down
22 changes: 19 additions & 3 deletions source/Private/Get-ClassResourceProperty.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,29 @@ function Get-ClassResourceProperty
{
$dscResourceAst = Get-ClassAst -ClassName $currentClassName -ScriptFile $BuiltModuleScriptFilePath

$sourceFilePath = Join-Path -Path $SourcePath -ChildPath ('Classes/???.{0}.ps1' -f $currentClassName)
$classExists = $false
$sourceFilePath = ''
$childPaths = @(
('Classes/???.{0}.ps1' -f $currentClassName)
('Classes/{0}.ps1' -f $currentClassName)
)

foreach ($childPath in $childPaths)
{
$sourceFilePath = Join-Path -Path $SourcePath -ChildPath $childPath

if ((Test-Path -Path $sourceFilePath))
{
$classExists = $true
break
}
}

<#
Skip if the class's source file does not exist. Thi can happen if the
Skip if the class's source file does not exist. This can happen if the
class uses a parent class from a different module.
#>
if (-not (Test-Path -Path $sourceFilePath))
if (-not $classExists)
{
continue
}
Expand Down

0 comments on commit 5bd7ef8

Please sign in to comment.