Spaces:
Sleeping
Sleeping
File size: 676 Bytes
42c32ad | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Loads a simple KEY=VALUE .env file into the current PowerShell session.
# Usage: .\scripts\load_env.ps1 .env.aws.local
param([Parameter(Mandatory = $true)][string]$Path)
if (-not (Test-Path -LiteralPath $Path)) {
Write-Error "Env file not found: $Path"
}
$count = 0
Get-Content -LiteralPath $Path | ForEach-Object {
$line = $_.Trim()
if ($line -eq "" -or $line.StartsWith("#")) { return }
if ($line -match '^\s*([^=]+?)\s*=\s*(.*)$') {
$k = $matches[1].Trim()
$v = $matches[2].Trim().Trim('"').Trim("'")
Set-Item -Path "env:$k" -Value $v
$count++
}
}
Write-Host "✔ Loaded $count vars from $Path" -ForegroundColor Green
|