Files
shop-server/scripts/read-deploy-env.ps1
T
@kirill.komarov e67d8bdc0a deploy
2026-05-10 16:49:55 +05:00

15 lines
610 B
PowerShell

function Import-DeployDotEnv {
param([string]$Path)
if (-not (Test-Path $Path)) { return }
Get-Content $Path | ForEach-Object {
if ($_ -match '^\s*#' -or $_ -match '^\s*$') { return }
if ($_ -match '^([A-Za-z_][A-Za-z0-9_]*)=(.*)$') {
$name = $Matches[1]; $raw = $Matches[2].Trim()
$v = $raw
if ($raw.StartsWith("'") -and $raw.EndsWith("'")) { $v = $raw.Trim("'") }
elseif ($raw.StartsWith('"') -and $raw.EndsWith('"')) { $v = $raw.Trim('"') }
[Environment]::SetEnvironmentVariable($name, $v, "Process")
}
}
}