Advanced Batch Scripting — Professional Automation Scripts
Write modular, reusable batch scripts with functions and proper error handling:
Complete Deployment Script:
```cmd
@echo off
setlocal
set APP_NAME=nextsem
set BUILD_DIR=out
call :check_prerequisites
if errorlevel 1 goto :error
call :run_tests
if errorlevel 1 goto :error
call :build_app
if errorlevel 1 goto :error
call :deploy_to_firebase
if errorlevel 1 goto :error
echo ✅ Deployment complete!
goto :eof
:check_prerequisites
echo Checking prerequisites...
where npm >nul 2>&1 || (echo npm not found! & exit /b 1)
where git >nul 2>&1 || (echo git not found! & exit /b 1)
exit /b 0
:run_tests
echo Running tests...
npm test
exit /b %errorlevel%
:build_app
echo Building app...
npm run build
exit /b %errorlevel%
:deploy_to_firebase
echo Deploying...
npx firebase deploy --only hosting
exit /b %errorlevel%
:error
echo ❌ Deployment failed at step: %errorlevel%
exit /b 1
`
This is production-quality batch scripting — reusable functions, clean error handling! 💪
