@@ -6,17 +6,25 @@ Describe "Node.js" {
66
77 BeforeAll {
88 function Get-UseNodeLogs {
9- # GitHub Windows images don't have `HOME` variable
10- $homeDir = $env: HOME ?? $env: HOMEDRIVE
11-
12- $possiblePaths = @ (
13- Join-Path - Path $homeDir - ChildPath " actions-runner/cached/_diag/pages"
14- Join-Path - Path $homeDir - ChildPath " runners/*/_diag/pages"
15- Join-Path - Path $homeDir - ChildPath " actions-runner/extracted/_diag/pages"
16- )
9+ $runnerProc = Get-Process - Name " Runner.Listener" - ErrorAction SilentlyContinue | Select-Object - First 1
10+ # Write-Host "`$runnerProc: $($runnerProc | Out-String)"
11+ if (-not $runnerProc -or -not $runnerProc.Path ) {
12+ Write-Error " Runner.Listener process not found."
13+ return
14+ }
15+ # Go up two directories to get runner root
16+ $runnerRoot = Split-Path (Split-Path $runnerProc.Path - Parent) - Parent
17+ # Write-Host "`$runnerRoot: $runnerRoot"
18+ # Recursively find all _diag/pages folders under the runner root directory
19+ $possiblePaths = Get-ChildItem - Path $runnerRoot - Directory - Recurse - Depth 4 - ErrorAction SilentlyContinue |
20+ Where-Object { $_.FullName -like " *_diag\pages" -or $_.FullName -like " *_diag/pages" }
21+ Write-Host " LogsPaths:"
22+ $possiblePaths | ForEach-Object { Write-Host $_.FullName }
1723
1824 $logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object - First 1
19- $resolvedPath = Resolve-Path - Path $logsFolderPath - ErrorAction SilentlyContinue
25+ if ($logsFolderPath ) {
26+ $resolvedPath = Resolve-Path - Path $logsFolderPath - ErrorAction SilentlyContinue
27+ }
2028
2129 if ($resolvedPath -and -not [string ]::IsNullOrEmpty($resolvedPath.Path ) -and (Test-Path $resolvedPath.Path )) {
2230 $useNodeLogFile = Get-ChildItem - Path $resolvedPath | Where-Object {
0 commit comments