param( [switch]$Install ) $ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path $frontendDir = Join-Path $repoRoot "frontend" if (-not (Test-Path $frontendDir)) { throw "Frontend directory not found: $frontendDir" } Push-Location $frontendDir try { if ($Install -or -not (Test-Path (Join-Path $frontendDir "node_modules"))) { Write-Host "[frontend] Installing dependencies..." -ForegroundColor Cyan npm install if ($LASTEXITCODE -ne 0) { throw "npm install failed" } } Write-Host "[frontend] Starting Astro dev server..." -ForegroundColor Green npm run dev if ($LASTEXITCODE -ne 0) { throw "npm run dev failed" } } finally { Pop-Location }