status-react/scripts/wait-for-metro-port.sh
Sean Hagstrom 89828ba7fd
chore: allow for overriding metro server port (#20202)
This change will now allow for customizing the port number when running the metro server. The environment variable `RCT_METRO_PORT` can now be set when executing commands like `make run-ios`, `make run ios-device`, and `make run-android`. Though, it should be noted that `make clean` may need to be ran before attempting to set or change `RCT_METRO_PORT` since the react-native app will have statically built code that references the value of RCT_METRO_PORT from compile time and not runtime.
2024-08-05 12:48:35 +01:00

15 lines
258 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
TIMEOUT=10 # Metro should not take this long to start.
while [ "${TIMEOUT}" -gt 0 ]; do
if ! lsof -i:"${RCT_METRO_PORT:-8081}" &> /dev/null; then
echo "."
sleep 1
((TIMEOUT--))
else
break
fi
done