From e1489bef3efab903b85cdf37ebe5209063802fc6 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Tue, 13 Sep 2016 20:52:39 -0700 Subject: [PATCH] use ruby instead of jq to parse json from simctl in reset-simulators.sh --- scripts/reset-simulators.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/reset-simulators.sh b/scripts/reset-simulators.sh index b87a1d6de4..136b05df75 100755 --- a/scripts/reset-simulators.sh +++ b/scripts/reset-simulators.sh @@ -14,14 +14,14 @@ while pgrep -q Simulator; do done # Shut down booted simulators -xcrun simctl list devices -j | jq -c -r '.devices | flatten | map(select(.availability == "(available)")) | map(select(.state == "Booted")) | map(.udid) | .[]' | while read udid; do +xcrun simctl list devices -j | ruby -rjson -e 'puts JSON.parse($stdin.read)["devices"].flat_map { |d| d[1] }.select { |d| d["state"] == "Booted" && d["availability"] == "(available)" }.map { |d| d["udid"] }' | while read udid; do echo "shutting down simulator with ID: $udid" xcrun simctl shutdown $udid done # Erase all available simulators echo "erasing simulators" -xcrun simctl list devices -j | jq -c -r '.devices | flatten | map(select(.availability == "(available)")) | map(.udid) | .[]' | while read udid; do +xcrun simctl list devices -j | ruby -rjson -e 'puts JSON.parse($stdin.read)["devices"].flat_map { |d| d[1] }.select { |d| d["availability"] == "(available)" }.map { |d| d["udid"] }' | while read udid; do xcrun simctl erase $udid & done wait @@ -32,7 +32,7 @@ fi # Wait until the boot completes echo "waiting for simulator to boot..." -while xcrun simctl list devices -j | jq -c -r '.devices | flatten | map(select(.availability == "(available)")) | map(select(.state == "Booted")) | length' | grep 0 >/dev/null; do +until xcrun simctl list devices -j | ruby -rjson -e 'exit JSON.parse($stdin.read)["devices"].flat_map { |d| d[1] }.any? { |d| d["state"] == "Booted" }'; do sleep 1 done