11 lines
350 B
PowerShell
11 lines
350 B
PowerShell
# 从 .env 读取 API_PORT,默认 8788
|
||
param([string]$Root = (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)))
|
||
$port = 8788
|
||
$envFile = Join-Path $Root ".env"
|
||
if (Test-Path $envFile) {
|
||
Get-Content $envFile | ForEach-Object {
|
||
if ($_ -match '^\s*API_PORT\s*=\s*(\d+)') { $port = [int]$Matches[1] }
|
||
}
|
||
}
|
||
Write-Output $port
|