-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrun.bat
More file actions
34 lines (25 loc) · 732 Bytes
/
Copy pathrun.bat
File metadata and controls
34 lines (25 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@echo off
setlocal EnableExtensions
cd /d "%~dp0"
if not defined PORT set "PORT=4317"
if not defined VITE_PORT set "VITE_PORT=5173"
call :kill_port_processes "%PORT%"
if errorlevel 1 exit /b %errorlevel%
call :kill_port_processes "%VITE_PORT%"
if errorlevel 1 exit /b %errorlevel%
if not exist "node_modules" (
echo Installing dependencies...
call npm install
if errorlevel 1 exit /b %errorlevel%
)
call npm run dev
exit /b %errorlevel%
:kill_port_processes
set "TARGET_PORT=%~1"
set "FOUND_PID="
for /f "tokens=5" %%P in ('netstat -ano -p tcp ^| findstr /R /C:":%TARGET_PORT% .*LISTENING"') do (
set "FOUND_PID=1"
echo Stopping process on port %TARGET_PORT%: %%P
taskkill /PID %%P /T /F >nul 2>nul
)
exit /b 0