Skip to content

Commit 1d1e319

Browse files
Add test-example.ps1
1 parent f8722fc commit 1d1e319

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

test-example.ps1

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
param (
2+
[string]$version = "latest"
3+
)
4+
$branchName = $env:branchName
5+
6+
Write-Host "Branch name: $branchName"
7+
$global:errorCode = 0
8+
9+
function Process-JavaScriptProjects {
10+
param (
11+
[string]$Path = ".",
12+
[string[]]$Folders = @("jQuery", "Angular", "Vue", "React")
13+
)
14+
Write-Host "Processing JavaScript Projects"
15+
16+
foreach ($folder in $Folders) {
17+
if (-not (Test-Path $folder)) {
18+
Write-Host "Directory $folder does not exist. Skipping..."
19+
continue
20+
}
21+
22+
Write-Host "`nProcessing folder: $folder"
23+
24+
Set-Location $folder
25+
26+
Write-Host "Running 'npm install' in $folder"
27+
$installResult = & npm install --loglevel=error -PassThru
28+
if ($LASTEXITCODE -ne 0) {
29+
Write-Error "npm install failed in $folder"
30+
$global:errorCode = 1
31+
}
32+
33+
Write-Host "Running 'npm run build' in $folder"
34+
$buildResult = & npm run build
35+
if ($LASTEXITCODE -ne 0) {
36+
Write-Error "npm run build failed in $folder"
37+
$global:errorCode = 1
38+
}
39+
40+
Set-Location ..
41+
}
42+
}
43+
44+
function Process-DotNetProjects {
45+
param (
46+
[string]$RootDirectory = "."
47+
)
48+
Write-Host "`nProcessing .NET Projects"
49+
50+
$slnFiles = Get-ChildItem -Path $RootDirectory -Filter *.sln -Recurse -Depth 1
51+
52+
if ($slnFiles.Count -eq 0) {
53+
Write-Host "No solution files (.sln) found in the specified directory at level 1."
54+
$global:errorCode = 1
55+
return
56+
}
57+
58+
foreach ($slnFile in $slnFiles) {
59+
Write-Host "Found solution file: $($slnFile.FullName)"
60+
61+
dotnet build $slnFile.FullName -c Release
62+
63+
if ($LASTEXITCODE -eq 0) {
64+
Write-Host "Build succeeded for $($slnFile.FullName)."
65+
} else {
66+
Write-Error "Build failed for $($slnFile.FullName)."
67+
$global:errorCode = 1
68+
}
69+
}
70+
}
71+
72+
Write-Host "Version: $version"
73+
Process-JavaScriptProjects
74+
Process-DotNetProjects
75+
76+
Write-Host "Error code: $global:errorCode"
77+
78+
exit $global:errorCode

0 commit comments

Comments
 (0)