@@ -8,13 +8,30 @@ Describe "Node.js" {
8
8
function Get-UseNodeLogs {
9
9
# GitHub Windows images don't have `HOME` variable
10
10
$homeDir = $env: HOME ?? $env: HOMEDRIVE
11
- $logsFolderPath = Join-Path - Path $homeDir - ChildPath " runners/*/_diag/pages" - Resolve
12
-
13
- $useNodeLogFile = Get-ChildItem - Path $logsFolderPath | Where-Object {
14
- $logContent = Get-Content $_.Fullname - Raw
15
- return $logContent -match " setup-node@v"
16
- } | Select-Object - First 1
17
- return $useNodeLogFile.Fullname
11
+
12
+ $possiblePaths = @ (
13
+ Join-Path - Path $homeDir - ChildPath " actions-runner/cached/_diag/pages"
14
+ Join-Path - Path $homeDir - ChildPath " runners/*/_diag/pages"
15
+ )
16
+
17
+ $logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object - First 1
18
+ $resolvedPath = Resolve-Path - Path $logsFolderPath - ErrorAction SilentlyContinue
19
+
20
+ if ($resolvedPath -and -not [string ]::IsNullOrEmpty($resolvedPath.Path ) -and (Test-Path $resolvedPath.Path )) {
21
+ $useNodeLogFile = Get-ChildItem - Path $resolvedPath | Where-Object {
22
+ $logContent = Get-Content $_.Fullname - Raw
23
+ return $logContent -match " setup-node@v"
24
+ } | Select-Object - First 1
25
+
26
+ # Return the file name if a match is found
27
+ if ($useNodeLogFile ) {
28
+ return $useNodeLogFile.FullName
29
+ } else {
30
+ Write-Error " No matching log file found in the specified path: $ ( $resolvedPath.Path ) "
31
+ }
32
+ } else {
33
+ Write-Error " The provided logs folder path is null, empty, or does not exist: $logsFolderPath "
34
+ }
18
35
}
19
36
}
20
37
0 commit comments