fix: harden Windows startup and rebuild release
This commit is contained in:
56
start.bat
56
start.bat
@@ -1,20 +1,64 @@
|
||||
@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 >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo [ERROR] Node.js not found. Please install Node.js first.
|
||||
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
|
||||
)
|
||||
|
||||
if not exist node_modules (
|
||||
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...
|
||||
npm install
|
||||
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 server.js
|
||||
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%
|
||||
|
||||
Reference in New Issue
Block a user