Skip to content

Commit

Permalink
Update AddTokenToLabVIEW.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
svelderrainruiz committed Dec 21, 2024
1 parent f940193 commit c10b8d1
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions .github/scripts/powershell/AddTokenToLabVIEW.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
# Example: .\AddTokenToLabVIEW.ps1 -MinimumSupportedLVVersion "2021" -SupportedBitness "64" -RelativePath "C:\labview-icon-editor"

param(
[Parameter(Mandatory=$true)]
[string]$MinimumSupportedLVVersion,
[Parameter(Mandatory=$true)]
[string]$SupportedBitness,
[Parameter(Mandatory=$true)]
[string]$RelativePath
)

# Construct the command
$script = @"
g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness -v "$RelativePath\Tooling\deployment\Create_LV_INI_Token.vi" -- "LabVIEW" "Localhost.LibraryPaths" "$RelativePath"
"@
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$DebugPreference = 'Continue'

Write-Debug "AddTokenToLabVIEW.ps1: Starting"
Write-Debug "Parameters:"
Write-Debug " MinimumSupportedLVVersion: $MinimumSupportedLVVersion"
Write-Debug " SupportedBitness: $SupportedBitness"
Write-Debug " RelativePath: $RelativePath"
Write-Debug "PowerShell Version: $($PSVersionTable.PSVersion)"

Write-Output "Executing the following command:"
Write-Output $script
# Construct the command as a list of arguments to avoid using Invoke-Expression
$command = 'g-cli'
$args = @(
'--lv-ver', $MinimumSupportedLVVersion,
'--arch', $SupportedBitness,
'-v', "$RelativePath\Tooling\deployment\Create_LV_INI_Token.vi",
'--', 'LabVIEW', 'Localhost.LibraryPaths', $RelativePath
)

Write-Host "Executing the following command:"
Write-Host "$command $($args -join ' ')"

# Execute the command and check for errors
try {
Invoke-Expression $script
# Execute the command directly
& $command $args

# Check the exit code of the executed command
if ($LASTEXITCODE -eq 0) {
Write-Host "Create localhost.library path from ini file"
} else {
Write-Error "Command failed with exit code: $LASTEXITCODE"
exit 1
}
} catch {
Write-Host ""
exit 0
}
Write-Error "An unexpected error occurred while executing g-cli."
Write-Error "Error Details: $($_.Exception.Message)"
exit 1
}

Write-Debug "AddTokenToLabVIEW.ps1: Completed Successfully."

0 comments on commit c10b8d1

Please sign in to comment.