Skip to content

Commit 2d03c1b

Browse files
Refactor compilerHelper.ps1 to limit .c file search to ../src and improve error messaging for specified files
1 parent d28dc53 commit 2d03c1b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

tool/compilerHelper.ps1

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ function Write-CustomError {
1313
}
1414
}
1515

16-
# Get .c files in current directory, ../src, or ./src
16+
# Get .c files only in ..\src
1717
$cFiles = @()
18-
foreach ($dir in @(".", "..\src", ".\src")) {
19-
if (Test-Path $dir) {
20-
$cFiles += Get-ChildItem -Path $dir -Filter *.c -File | ForEach-Object { $_.FullName }
21-
}
18+
if (Test-Path "..\src") {
19+
$cFiles += Get-ChildItem -Path "..\src" -Filter *.c -File | ForEach-Object { $_.FullName }
2220
}
2321
if (-not $cFiles) {
2422
Write-CustomError "No .c files found in current directory. Exiting."
@@ -39,10 +37,10 @@ foreach ($arg in $args) {
3937
$filesToCompile = @()
4038
if ($specifiedFiles.Count -gt 0) {
4139
foreach ($file in $specifiedFiles) {
42-
if ($cFiles -contains $file) {
43-
$filesToCompile += $file
40+
if ($cFiles | Where-Object { [System.IO.Path]::GetFileName($_) -eq $file }) {
41+
$filesToCompile += ( $cFiles | Where-Object { [System.IO.Path]::GetFileName($_) -eq $file } )
4442
} else {
45-
Write-CustomError "Specified file not found: $file"
43+
Write-CustomError "Specified file not found in ..\src: $file"
4644
}
4745
}
4846
} elseif ($acceptAll) {

0 commit comments

Comments
 (0)