From dbd1b7e70b2cd6189ea1093cbb3b3113dcc713bf Mon Sep 17 00:00:00 2001 From: Tyler Matijevich Date: Wed, 28 Dec 2022 16:36:55 -0600 Subject: [PATCH] Search for program file inside of program directory in case of multiple directories. See #6. --- BuildVersion.ps1 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/BuildVersion.ps1 b/BuildVersion.ps1 index 735a5a9..812f061 100644 --- a/BuildVersion.ps1 +++ b/BuildVersion.ps1 @@ -69,12 +69,17 @@ if(-not [System.IO.Directory]::Exists($LogicalPath)) { else { exit 0 } } $SearchProgram = Get-ChildItem -Path $LogicalPath -Filter $ProgramName -Recurse -Directory -Name -if($SearchProgram.Length -ne 0) { - $ProgramPath = $LogicalPath + $SearchProgram + "\" - Write-Host "BuildVersion: Located $ProgramName program at $ProgramPath" - $LocalVariableFile = $ProgramPath + "Variables.var" +$ProgramFound = $False +for($i = 0; $i -lt $SearchProgram.Length; $i++) { + $ProgramPath = $LogicalPath + $SearchProgram[$i] + "\" + if([System.IO.File]::Exists($ProgramPath + "ANSIC.prg")) { + $ProgramFound = $True + Write-Host "BuildVersion: Located $ProgramName program at $ProgramPath" + $LocalVariableFile = $ProgramPath + "Variables.var" + break + } } -else { +if(-NOT $ProgramFound) { Write-Host "BuildVersion: Unable to locate $ProgramName in $LogicalPath" $ProgramPath = "BadPath" $LocalVariableFile = "BadPath"