diff --git a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx index 7545f4554..85d809636 100644 --- a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx +++ b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx @@ -47,8 +47,8 @@ class IDBBridge implements IOSBridge { async screenshot(serial: string): Promise { const imagePath = makeTempScreenshotFilePath(); - const command = `idb screenshot --udid ${serial} ${imagePath}`; - return runScreenshotCommand(command, imagePath); + await exec(`idb screenshot --udid ${serial} ${imagePath}`); + return readScreenshotIntoBuffer(imagePath); } startLogListener( @@ -95,8 +95,8 @@ class SimctlBridge implements IOSBridge { async screenshot(serial: string): Promise { const imagePath = makeTempScreenshotFilePath(); - const command = `xcrun simctl io ${serial} screenshot ${imagePath}`; - return runScreenshotCommand(command, imagePath); + await exec(`xcrun simctl io ${serial} screenshot ${imagePath}`); + return readScreenshotIntoBuffer(imagePath); } async navigate(serial: string, location: string): Promise { @@ -144,11 +144,7 @@ function makeTempScreenshotFilePath() { return path.join(getFlipperServerConfig().paths.tempPath, imageName); } -async function runScreenshotCommand( - command: string, - imagePath: string, -): Promise { - await exec(command); +async function readScreenshotIntoBuffer(imagePath: string): Promise { const buffer = await fs.readFile(imagePath); await fs.unlink(imagePath); return buffer;