Skip to content

Commit 7ef97ea

Browse files
Update test-example.ps1
1 parent d0f8847 commit 7ef97ea

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

test-example.ps1

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
param (
22
[string]$version = "latest"
33
)
4+
$branchName = $env:branchName
5+
6+
Write-Host "Branch name: $branchName"
7+
$global:errorCode = 0
48

59
function Process-JavaScriptProjects {
610
param (
@@ -20,17 +24,17 @@ function Process-JavaScriptProjects {
2024
Set-Location $folder
2125

2226
Write-Host "Running 'npm install' in $folder"
23-
$installResult = & npm install -PassThru
27+
$installResult = & npm install --loglevel=error -PassThru
2428
if ($LASTEXITCODE -ne 0) {
2529
Write-Error "npm install failed in $folder"
26-
$errorCode = 1
30+
$global:errorCode = 1
2731
}
2832

2933
Write-Host "Running 'npm run build' in $folder"
30-
$buildResult = & npm run build -PassThru
34+
$buildResult = & npm run build
3135
if ($LASTEXITCODE -ne 0) {
3236
Write-Error "npm run build failed in $folder"
33-
$errorCode = 1
37+
$global:errorCode = 1
3438
}
3539

3640
Set-Location ..
@@ -41,13 +45,14 @@ function Process-DotNetProjects {
4145
param (
4246
[string]$RootDirectory = "."
4347
)
44-
Write-Host "`nProcessing .NET Projects";
48+
Write-Host "`nProcessing .NET Projects"
4549

4650
$slnFiles = Get-ChildItem -Path $RootDirectory -Filter *.sln -Recurse -Depth 1
4751

4852
if ($slnFiles.Count -eq 0) {
4953
Write-Host "No solution files (.sln) found in the specified directory at level 1."
50-
exit 1
54+
$global:errorCode = 1
55+
return
5156
}
5257

5358
foreach ($slnFile in $slnFiles) {
@@ -58,16 +63,16 @@ function Process-DotNetProjects {
5863
if ($LASTEXITCODE -eq 0) {
5964
Write-Host "Build succeeded for $($slnFile.FullName)."
6065
} else {
61-
Write-Host "Build failed for $($slnFile.FullName)."
62-
errorCode = 1;
66+
Write-Error "Build failed for $($slnFile.FullName)."
67+
$global:errorCode = 1
6368
}
6469
}
6570
}
6671

67-
$errorCode = 0;
68-
6972
Write-Host "Version: $version"
7073
Process-JavaScriptProjects
7174
Process-DotNetProjects
7275

73-
exit $errorCode
76+
Write-Host "Error code: $global:errorCode"
77+
78+
exit $global:errorCode

0 commit comments

Comments
 (0)