Asyncify screenshot helper
Summary: Suggested by mweststrate. Much more readable now! Reviewed By: mweststrate Differential Revision: D30251322 fbshipit-source-id: 269fefce3f63fa4eababb4c541ff09a660cc5cc0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
757ba91bf6
commit
7df77e2620
@@ -97,16 +97,14 @@ function makeTempScreenshotFilePath() {
|
||||
return path.join(directory, imageName);
|
||||
}
|
||||
|
||||
function runScreenshotCommand(
|
||||
async function runScreenshotCommand(
|
||||
command: string,
|
||||
imagePath: string,
|
||||
): Promise<Buffer> {
|
||||
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<Buffer> {
|
||||
|
||||
Reference in New Issue
Block a user