From b28239229f165920b8edcc8f58db0065c78b4e68 Mon Sep 17 00:00:00 2001 From: Anton Kastritskiy Date: Tue, 21 May 2024 04:59:55 -0700 Subject: [PATCH] handle empty output from idb list-targets Summary: `idb list-targets --json` outputs empty string, which is not a valid JSON. Reviewed By: nikoant Differential Revision: D57614884 fbshipit-source-id: 572e9e5e44be1cde04d0c74fbff44a92d2a72fd3 --- desktop/doctor/src/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/desktop/doctor/src/index.tsx b/desktop/doctor/src/index.tsx index ea932b89bd6..13150861ba3 100644 --- a/desktop/doctor/src/index.tsx +++ b/desktop/doctor/src/index.tsx @@ -279,8 +279,14 @@ export function getHealthchecks(): FlipperDoctor.Healthchecks { const devices = result.stdout .trim() .split('\n') - .map((x) => JSON.parse(x)) - .filter((x) => x.type === 'simulator'); + .map((x) => { + try { + return JSON.parse(x); + } catch (e) { + return null; + } + }) + .filter((x) => x != null && x.type === 'simulator'); if (devices.length === 0) { return {