I've been trying since yesterday to translate a .bat file into bash but without success because I don't know enough about the subtleties of each command, especially the call, so if anyone can do it, at least take a look for m 'to help.
@echo off
echo Installing/updating bot dependencies
call npm ci --only=production --loglevel=warn >NUL
if NOT ["%errorlevel%"]==["0"] (
pause
exit /b %errorlevel%
)
echo Starting the bot
call npm run start
if NOT ["%errorlevel%"]==["0"] (
pause
exit /b %errorlevel%
)
CodePudding user response:
Here is the translation:
#!/bin/bash
echo "Installing/updating bot dependencies"
npm ci --only=production --loglevel=warn >/dev/null
exit_code=$?
if [ ${exit_code} -ne 0 ]; then
read -p "Press ENTER to exit."
exit ${exit_code}
fi
echo Starting the bot
npm run start
exit_code=$?
if [ ${exit_code} -ne 0 ]; then
read -p "Press ENTER to exit."
exit ${exit_code}
fi