Update samy.ps1

This commit is contained in:
2025-12-21 00:06:32 -05:00
parent b9a9c7c8f2
commit 6c12c0071d

View File

@@ -121,6 +121,36 @@ $ConfirmPreference = 'None'
} }
. ([ScriptBlock]::Create($functionsContent)) . ([ScriptBlock]::Create($functionsContent))
# 3) Load remote functions (must be before calling them)
try {
Write-Host "[Info] Loading functions from: $Script:SamyFunctionsUrl" -ForegroundColor Cyan
$functionsContent = (Invoke-WebRequest -UseBasicParsing $Script:SamyFunctionsUrl -ErrorAction Stop).Content
if ([string]::IsNullOrWhiteSpace($functionsContent)) {
throw "Downloaded content was empty."
}
# quick sanity check: make sure the file looks like it contains your function
if ($functionsContent -notmatch '(?im)^\s*function\s+Initialize-NuGetProvider\b') {
Write-Host "[Warning] samy.functions.ps1 loaded, but Initialize-NuGetProvider not found in content." -ForegroundColor Yellow
}
# Load functions into the current scope
. ([ScriptBlock]::Create($functionsContent))
# Verify the function is now available
if (Get-Command Initialize-NuGetProvider -ErrorAction SilentlyContinue) {
Write-Host "[Success] Initialize-NuGetProvider is loaded and available." -ForegroundColor Green
}
else {
throw "Dot-sourcing completed, but Initialize-NuGetProvider is still not available."
}
}
catch {
throw "Failed to load samy.functions.ps1 from $Script:SamyFunctionsUrl. $($_.Exception.Message)"
}
# 4) Now call functions that live in samy.functions.ps1 # 4) Now call functions that live in samy.functions.ps1
# Initialize-NuGetProvider # Initialize-NuGetProvider