From 7df77e2620c102eaf0100ff73d31b0ef103a22ec Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 11 Aug 2021 11:02:10 -0700 Subject: [PATCH] Asyncify screenshot helper Summary: Suggested by mweststrate. Much more readable now! Reviewed By: mweststrate Differential Revision: D30251322 fbshipit-source-id: 269fefce3f63fa4eababb4c541ff09a660cc5cc0 --- desktop/app/src/utils/IOSBridge.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/desktop/app/src/utils/IOSBridge.tsx b/desktop/app/src/utils/IOSBridge.tsx index d65b95e80..7f7aa2a7f 100644 --- a/desktop/app/src/utils/IOSBridge.tsx +++ b/desktop/app/src/utils/IOSBridge.tsx @@ -97,16 +97,14 @@ function makeTempScreenshotFilePath() { return path.join(directory, imageName); } -function runScreenshotCommand( +async function runScreenshotCommand( command: string, imagePath: string, ): Promise { - return exec(command) - .then(() => fs.readFile(imagePath)) - .then(async (buffer) => { - await fs.unlink(imagePath); - return buffer; - }); + await exec(command); + const buffer = await fs.readFile(imagePath); + await fs.unlink(imagePath); + return buffer; } export async function xcrunScreenshot(serial: string): Promise {