run_windows.bat 1.68 KB
@echo off
setlocal DisableDelayedExpansion
chcp 65001 >nul
rem Amap reverse-geocoding fill tool (TypeScript) Windows launcher.
rem Keep this file pure ASCII with CRLF endings: cmd.exe mis-parses batch
rem files that contain non-ASCII bytes or bare LF line endings.
if defined NODE_EXE goto explicit_node
where node >nul 2>&1
if errorlevel 1 goto missing_node
set "NODE_CMD=node"
goto check_version
:explicit_node
if not exist "%NODE_EXE%" goto invalid_node
set "NODE_CMD=%NODE_EXE%"
:check_version
"%NODE_CMD%" -e "const [a,b]=process.versions.node.split('.').map(Number);process.exit(a>22||(a===22&&b>=18)?0:1)" >nul 2>&1
if errorlevel 1 goto old_node
if not exist "%~dp0node_modules\csv-parse" goto missing_modules
if not exist "%~dp0node_modules\xlsx" goto missing_modules
"%NODE_CMD%" --disable-warning=ExperimentalWarning "%~dp0src\run-tool.ts" %*
set "AMAP_EXIT_CODE=%errorlevel%"
goto finish
:old_node
echo Node.js 22.18 or newer is required. Install it and enable Add to PATH,
echo or set NODE_EXE to the full path of node.exe before running this file.
set "AMAP_EXIT_CODE=1"
goto finish
:invalid_node
echo NODE_EXE does not point to a readable node.exe.
set "AMAP_EXIT_CODE=1"
goto finish
:missing_node
echo Node.js was not found in PATH.
echo Install Node.js 22.18 or newer, or set NODE_EXE to the full path of node.exe.
set "AMAP_EXIT_CODE=1"
goto finish
:missing_modules
echo node_modules is missing. Run: npm install --omit=dev
echo in this tool folder, or use the package that already contains node_modules.
set "AMAP_EXIT_CODE=1"
goto finish
:finish
echo.
echo Exit code: %AMAP_EXIT_CODE%  (0=complete, 2=output with missing fields, 130=interrupted)
if not defined AMAP_NO_PAUSE pause
exit /b %AMAP_EXIT_CODE%