Files
cc-web/start.bat

65 lines
1.3 KiB
Batchfile

@echo off
setlocal
chcp 65001 >nul 2>&1
cd /d "%~dp0"
if errorlevel 1 (
echo [ERROR] Failed to open the CC-Web directory.
pause
exit /b 1
)
where node.exe >nul 2>&1
if errorlevel 1 (
echo [ERROR] Node.js was not found. Install Node.js 18 or later first.
echo https://nodejs.org/
pause
exit /b 1
)
node.exe -e "process.exit(Number(process.versions.node.split('.')[0]) >= 18 ? 0 : 1)"
if errorlevel 1 (
echo [ERROR] Node.js 18 or later is required. Current version:
node.exe --version
pause
exit /b 1
)
where npm.cmd >nul 2>&1
if errorlevel 1 (
echo [ERROR] npm was not found. Reinstall Node.js with npm enabled.
echo https://nodejs.org/
pause
exit /b 1
)
call npm.cmd ls --depth=0 >nul 2>&1
if errorlevel 1 (
echo Installing dependencies...
call :install_dependencies
if errorlevel 1 (
echo [ERROR] Failed to install dependencies. Check the npm output above.
pause
exit /b 1
)
)
echo Starting CC-Web...
node.exe server.js
set "APP_EXIT_CODE=%ERRORLEVEL%"
if not "%APP_EXIT_CODE%"=="0" (
echo [ERROR] CC-Web stopped with exit code %APP_EXIT_CODE%.
)
pause
exit /b %APP_EXIT_CODE%
:install_dependencies
if exist "package-lock.json" (
call npm.cmd ci
) else (
call npm.cmd install
)
set "INSTALL_EXIT_CODE=%ERRORLEVEL%"
exit /b %INSTALL_EXIT_CODE%