Files
GitJournal/scripts/flutter_run.sh
Vishesh Handa a065cd3ec8 Improve flutter_run script
* Display a longer message when reloading - It's easier to see
* Make flutter_run start the reload script and kill it automatically.
This is always the behaviour I want when running an app via flutter run.
2019-05-02 00:19:45 +02:00

25 lines
488 B
Bash
Executable File

#!/usr/bin/env bash
set -eu
cd "$(dirname "$0")"
touch /tmp/flutter.pid
./reload.sh &
BGPID=$!
trap 'kill $BGPID; exit' SIGINT
cd ../
DEVICES=$(adb devices -l | tail -n +2)
NUM_DEVICES=$(echo "$DEVICES" | wc -l)
if [ "$NUM_DEVICES" = 1 ]; then
DEVICE_ID="$DEVICES"
else
DEVICE_ID=$(echo "$DEVICES" | fzf)
fi
DEVICE_ID=$(echo "$DEVICE_ID" | awk '{ print $1 }')
echo "Running on $DEVICE_ID"
flutter run -d "$DEVICE_ID" --pid-file /tmp/flutter.pid --observatory-port 8888 "$@"