From 306a7038846ea38cb7630a97e5e62d860b5ee80c Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Wed, 14 Apr 2021 18:28:37 -0700 Subject: [PATCH] Handle empty files in Test-SampleMetadata Relates to Azure/azure-sdk-for-java#20684 --- eng/common/scripts/Test-SampleMetadata.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Test-SampleMetadata.ps1 b/eng/common/scripts/Test-SampleMetadata.ps1 index cd74690cae573..523aeb31dd8a8 100644 --- a/eng/common/scripts/Test-SampleMetadata.ps1 +++ b/eng/common/scripts/Test-SampleMetadata.ps1 @@ -31,11 +31,13 @@ process { } [string[]] $content = $file | Get-Content - if (!$content[0].StartsWith('---')) { + if (!$content -or !$content[0].StartsWith('---')) { Write-Verbose "Skipping $($file.FullName): does not contain frontmatter" continue } + Write-Verbose "Checking $($file.FullName)" + # Reset metadata and create mutable collections. $products = [System.Collections.Generic.List[string]]::new()