1#!/usr/bin/env bash 2 3function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/$d}"; } 4 5command="instruments" 6 7function setTraceTemplate { 8 # Finds the default Automation trace template file. 9 traceTemplate=$(find /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments -type f -name "Automation.tracetemplate") 10 if [[ -z "${traceTemplate}" ]] 11 then 12 echo "Error: Could not find Automation.tracetemplate" >&2 13 exit 1 14 else 15 command="${command} -t \"${traceTemplate}\"" 16 fi 17} 18 19 20APP=$1 21PLATFORM=$2 22MODULES=$(join_by , "${@:3}") 23LINK="bareexpo://${APP}/run?tests=${MODULES}" 24 25echo " ☛ Opening ${MODULES} in ${APP}..." 26if [ $PLATFORM = "android" ]; then 27 echo $(adb shell am start -W -a android.intent.action.VIEW -d "$LINK" dev.expo.payments) 28elif [ $PLATFORM = "ios" ]; then 29 # CONNECTED_DEVICE=$(node ios-deploy -c | grep -oE 'Found ([0-9A-Za-z\-]+)' | sed 's/Found //g') 30 # if [ -z "${CONNECTED_DEVICE}" ]; then 31 $(xcrun simctl openurl booted $LINK) 32 # else 33 # $(xcrun simctl openurl $CONNECTED_DEVICE $LINK) 34 # fi 35else 36 $(xcrun simctl openurl booted $LINK) 37 echo $(adb shell am start -W -a android.intent.action.VIEW -d "$LINK" dev.expo.payments) 38fi