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);
|
return path.join(directory, imageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function runScreenshotCommand(
|
async function runScreenshotCommand(
|
||||||
command: string,
|
command: string,
|
||||||
imagePath: string,
|
imagePath: string,
|
||||||
): Promise<Buffer> {
|
): Promise<Buffer> {
|
||||||
return exec(command)
|
await exec(command);
|
||||||
.then(() => fs.readFile(imagePath))
|
const buffer = await fs.readFile(imagePath);
|
||||||
.then(async (buffer) => {
|
|
||||||
await fs.unlink(imagePath);
|
await fs.unlink(imagePath);
|
||||||
return buffer;
|
return buffer;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function xcrunScreenshot(serial: string): Promise<Buffer> {
|
export async function xcrunScreenshot(serial: string): Promise<Buffer> {
|
||||||
|
|||||||
Reference in New Issue
Block a user