修复bug

This commit is contained in:
dekun
2026-05-24 07:43:05 +08:00
parent a3218f4fbd
commit 4b5fae2946
6 changed files with 26 additions and 11 deletions
+12 -4
View File
@@ -62,6 +62,14 @@ function Should-Include([string]$Key, [string[]]$Selected) {
return $Selected -contains $Key
}
# 复制 .env 时统一为 LF,避免上传到 Linux 后 PM2 source 报 $'\r': command not found
function Copy-EnvFileLf([string]$Src, [string]$Dst) {
$raw = [System.IO.File]::ReadAllText($Src)
$lf = ($raw -replace "`r`n", "`n") -replace "`r", "`n"
$utf8NoBom = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText($Dst, $lf, $utf8NoBom)
}
function Setup-MonitorProject([hashtable]$Proj) {
$projPath = Join-Path $RepoRoot $Proj.Dir
if (-not (Test-Path $projPath)) {
@@ -94,8 +102,8 @@ function Setup-MonitorProject([hashtable]$Proj) {
$envExample = Join-Path $projPath ".env.example"
$envFile = Join-Path $projPath ".env"
if ((Test-Path $envExample) -and -not (Test-Path $envFile)) {
Copy-Item $envExample $envFile
Write-Host " 已复制 .env.example -> .env" -ForegroundColor Green
Copy-EnvFileLf $envExample $envFile
Write-Host " 已复制 .env.example -> .env (LF)" -ForegroundColor Green
} elseif (Test-Path $envFile) {
Write-Host " 保留已有 .env" -ForegroundColor DarkGray
} else {
@@ -147,8 +155,8 @@ function Setup-HubProject() {
$envExample = Join-Path $projPath ".env.example"
$envFile = Join-Path $projPath ".env"
if ((Test-Path $envExample) -and -not (Test-Path $envFile)) {
Copy-Item $envExample $envFile
Write-Host " 已复制 .env.example -> .env" -ForegroundColor Green
Copy-EnvFileLf $envExample $envFile
Write-Host " 已复制 .env.example -> .env (LF)" -ForegroundColor Green
}
}
Write-Host " 完成: $venvPy" -ForegroundColor Green