# Load KEY=VALUE pairs from .env into the current PowerShell process. # Usage: . .\tests\scripts\load-env.ps1 param( [string]$Path = ".env" ) if (-not (Test-Path $Path)) { Write-Error "env file not found: $Path" return } Get-Content $Path | ForEach-Object { $line = $_.Trim() if ($line -eq "" -or $line.StartsWith("#")) { return } $idx = $line.IndexOf("=") if ($idx -lt 1) { return } $key = $line.Substring(0, $idx).Trim() $val = $line.Substring($idx + 1).Trim() if (($val.StartsWith('"') -and $val.EndsWith('"')) -or ($val.StartsWith("'") -and $val.EndsWith("'"))) { $val = $val.Substring(1, $val.Length - 2) } [Environment]::SetEnvironmentVariable($key, $val, "Process") Write-Host " loaded $key" }