Created
July 26, 2020 15:33
-
-
Save somq/c165f351df665edb7948740746e31a3e to your computer and use it in GitHub Desktop.
ionic5-run-multiple-devices.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
default_port=8000 | |
deviceLst=$(adb devices | awk 'NR > 1 {print $1}' | sed ':a;N;$!ba;s/\n/ /g') | |
IFS=' ' read -a array <<< "$deviceLst" | |
## Clean old background processes | |
old_processes=$(pgrep -f 'sh -c ionic cordova run') | |
if [ ! -z "$old_processes" ]; then | |
echo "Killing old processes $old_processes..." | |
kill $(pgrep -f 'sh -c ionic cordova run') | |
else | |
echo "No old process found." | |
fi | |
## Run scripts in background | |
for i in "${!array[@]}" | |
do | |
port=$(($default_port + $i)) | |
echo "Running app on device => ${array[$i]} ($port)" | |
npm start -- --target="${array[$i]}" --port=$port & | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment