diff --git a/SPLIT-samy.ps1 b/SPLIT-samy.ps1 index b24ba1c..e1e0096 100644 --- a/SPLIT-samy.ps1 +++ b/SPLIT-samy.ps1 @@ -44,22 +44,18 @@ function Import-SamyChunk { [Parameter(Mandatory)][string]$Name ) - try { - Write-Host "[Info] Loading chunk: $Name" -ForegroundColor Cyan - $content = (Invoke-WebRequest -UseBasicParsing -Uri $Url -ErrorAction Stop).Content + Write-Host "[Info] Loading chunk: $Name" -ForegroundColor Cyan + $content = (Invoke-WebRequest -UseBasicParsing -Uri $Url -ErrorAction Stop).Content - if ([string]::IsNullOrWhiteSpace($content)) { - throw "Downloaded content was empty." - } + if ([string]::IsNullOrWhiteSpace($content)) { + throw "Downloaded content was empty." + } - . ([ScriptBlock]::Create($content)) - Write-Host "[Success] Loaded: $Name" -ForegroundColor Green - } - catch { - throw "Failed to load chunk '$Name' from $Url. $($_.Exception.Message)" - } + Write-Host "[Success] Downloaded: $Name" -ForegroundColor Green + return $content } + # Single source of truth for where chunks live # (Matches your current inline values) $Script:SamyGitURL = 'https://git.svstools.ca/SVS_Public_Repo/SAMY/raw/branch' @@ -107,9 +103,12 @@ $chunks = @( ) foreach ($c in $chunks) { - . Import-SamyChunk -Url $c.Url -Name $c.Name + $content = Import-SamyChunk -Url $c.Url -Name $c.Name + . ([ScriptBlock]::Create($content)) + Write-Host "[Success] Loaded: $($c.Name)" -ForegroundColor Green } + if (-not (Get-Command Invoke-ScriptAutomationMonkey -ErrorAction SilentlyContinue)) { throw "Bootstrap loaded chunks, but Invoke-ScriptAutomationMonkey was not found. Ensure src/core.ps1 defines it." }