From abceb802064c57f75850ec5ae79a560c2f35aba3 Mon Sep 17 00:00:00 2001 From: HarithaVattikuti <73516759+HarithaVattikuti@users.noreply.github.com> Date: Thu, 10 Jul 2025 17:25:26 -0500 Subject: [PATCH] Updated logic --- tests/Node.Tests.ps1 | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/tests/Node.Tests.ps1 b/tests/Node.Tests.ps1 index bb1ea9a..9743fa5 100644 --- a/tests/Node.Tests.ps1 +++ b/tests/Node.Tests.ps1 @@ -17,27 +17,12 @@ Describe "Node.js" { $logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1 $resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue - if (-not [string]::IsNullOrEmpty($resolvedPath) -and (Test-Path $resolvedPath)) { - if ($logsFolderPath -eq "actions-runner/cached/_diag/pages") { - try { - $useNodeLogFile = Get-ChildItem -Path $logsFolderPath -File| Where-Object { - if (-not $_.PSIsContainer) { # Ensure it's not a directory - $logContent = Get-Content $_.Fullname -Raw - return $logContent -match "setup-node@v" - } - } | Select-Object -First 1 - } catch { - Write-Error "Failed to resolve path: $logsFolderPath" - } - } else { - $useNodeLogFile = Get-ChildItem -Path $resolvedPath | Where-Object { - if (-not $_.PSIsContainer) { # Ensure it's not a directory + if ($resolvedPath -and -not [string]::IsNullOrEmpty($resolvedPath.Path) -and (Test-Path $resolvedPath.Path)) { + $useNodeLogFile = Get-ChildItem -Path $resolvedPath | Where-Object { $logContent = Get-Content $_.Fullname -Raw - return $logContent -match "setup-node@v" - } + return $logContent -match "setup-node@v" } | Select-Object -First 1 - } - + # Return the file name if a match is found if ($useNodeLogFile) { return $useNodeLogFile.FullName