2019-03-20 14:14:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script is executed bt Gradle to start the React packager for Debug
|
|
|
|
# targets.
|
|
|
|
|
|
|
|
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
|
|
|
|
|
|
|
|
export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}"
|
|
|
|
echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${THIS_DIR}/../../node_modules/react-native/scripts/.packager.env"
|
|
|
|
|
2020-08-10 09:51:33 +00:00
|
|
|
adb reverse tcp:$RCT_METRO_PORT tcp:$RCT_METRO_PORT
|
2019-07-11 16:13:46 +00:00
|
|
|
|
2019-03-20 14:14:42 +00:00
|
|
|
if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then
|
|
|
|
if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then
|
|
|
|
echo "Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
else
|
2020-08-10 09:50:31 +00:00
|
|
|
CMD="$THIS_DIR/run-packager-helper.command"
|
2019-03-20 14:14:42 +00:00
|
|
|
if [[ `uname` == "Darwin" ]]; then
|
|
|
|
open -g "${CMD}" || echo "Can't start packager automatically"
|
|
|
|
else
|
|
|
|
xdg-open "${CMD}" || echo "Can't start packager automatically"
|
|
|
|
fi
|
|
|
|
fi
|