Files
pleno-vue/scripts/start-playwright-dev-server.ps1
T
Jeppe Bundgaard bbbad2c634 Remove dependency on the ws module.
Deleted the entire `ws` library and its associated files. This likely reflects a move away from the WebSocket library, possibly signaling an alternate implementation or unused/legacy code cleanup.
2026-04-14 13:45:15 +02:00

46 lines
1.0 KiB
PowerShell

$ErrorActionPreference = "Stop"
param(
[int]$Port = 5173
)
function Get-ListeningProcess {
param([int]$TargetPort)
$listener = Get-NetTCPConnection -LocalPort $TargetPort -State Listen -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $listener) {
return $null
}
$process = Get-CimInstance Win32_Process -Filter "ProcessId = $($listener.OwningProcess)" -ErrorAction SilentlyContinue
if (-not $process) {
return $null
}
return [PSCustomObject]@{
Id = $listener.OwningProcess
CommandLine = [string]($process.CommandLine ?? "")
}
}
$existing = Get-ListeningProcess -TargetPort $Port
if ($existing) {
if ($existing.CommandLine -notmatch "vite(?:\.js)?") {
throw "Port $Port is already in use by a non-Vite process: $($existing.CommandLine)"
}
Stop-Process -Id $existing.Id -Force
Start-Sleep -Seconds 1
}
$npm = if (Get-Command npm.cmd -ErrorAction SilentlyContinue) {
"npm.cmd"
} else {
"npm"
}
& $npm run dev -- --host localhost --port $Port --strictPort
exit $LASTEXITCODE