Update samy.ps1
This commit is contained in:
30
samy.ps1
30
samy.ps1
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user