Skip to content

Commit 197084f

Browse files
Copilotpkbullock
andcommitted
Fix fault tolerance in report-cmdusage.ps1: case-insensitive README lookup and null check
Co-authored-by: pkbullock <8781041+pkbullock@users.noreply.github.com>
1 parent fdc1e9c commit 197084f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docfx/report-cmdusage.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ function GetReadme{
5252

5353
$readmeFilePath = Join-Path -Path $SamplePath -ChildPath "README.md"
5454

55+
# On case-sensitive file systems (e.g. Linux), try a case-insensitive fallback
56+
# if the exact path does not exist (e.g. readme.md instead of README.md)
57+
if(-not (Test-Path -Path $readmeFilePath)){
58+
$readmeFile = Get-ChildItem -Path $SamplePath | Where-Object { $_.Name -ieq "README.md" } | Select-Object -First 1
59+
if($readmeFile){
60+
$readmeFilePath = $readmeFile.FullName
61+
}else{
62+
Write-Host "Warning: README not found in $SamplePath"
63+
return $null
64+
}
65+
}
66+
5567
$content = Get-Content $readmeFilePath -Raw
5668

5769
return $content
@@ -122,6 +134,12 @@ $files | Foreach-Object {
122134
}
123135

124136
$content = GetReadme -SamplePath $_.Directory
137+
138+
if($null -eq $content){
139+
Write-Host "Warning: Skipping $($_.Directory.Name) - README.md could not be loaded"
140+
return
141+
}
142+
125143
$title = GetTitleFromSampleJson -SamplePath $_.Directory -DefaultReturn $_.Directory.Name
126144
$dirName = $_.Directory.Name
127145
$cmdletsUsed = ""

0 commit comments

Comments
 (0)