[strict[ ScreenCaptureButton
Summary: _typescript_ Reviewed By: jknoxville Differential Revision: D17282357 fbshipit-source-id: 6ddd912978faa30195f59971f19d29d3ea79342b
This commit is contained in:
committed by
Facebook Github Bot
parent
7e833b1d70
commit
ac120aa59c
@@ -119,8 +119,8 @@ class ScreenCaptureButtons extends Component<Props, State> {
|
||||
reportPlatformFailures(
|
||||
selectedDevice
|
||||
.screenshot()
|
||||
.then((buffer: Buffer) => writeBufferToFile(pngPath, buffer))
|
||||
.then((path: string) => openFile(path)),
|
||||
.then(buffer => writeBufferToFile(pngPath, buffer))
|
||||
.then(path => openFile(path)),
|
||||
'captureScreenshot',
|
||||
);
|
||||
}
|
||||
@@ -206,13 +206,15 @@ class ScreenCaptureButtons extends Component<Props, State> {
|
||||
dst: string,
|
||||
): Promise<string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
return device.adb.pull(device.serial, src).then(stream => {
|
||||
stream.on('end', () => {
|
||||
resolve(dst);
|
||||
return device.adb
|
||||
.pull(device.serial, src)
|
||||
.then((stream: NodeJS.ReadStream) => {
|
||||
stream.on('end', () => {
|
||||
resolve(dst);
|
||||
});
|
||||
stream.on('error', reject);
|
||||
stream.pipe(fs.createWriteStream(dst));
|
||||
});
|
||||
stream.on('error', reject);
|
||||
stream.pipe(fs.createWriteStream(dst));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -236,7 +238,7 @@ class ScreenCaptureButtons extends Component<Props, State> {
|
||||
return device.adb
|
||||
.shell(device.serial, command)
|
||||
.then(adb.util.readAll)
|
||||
.then(output => output.toString().trim());
|
||||
.then((output: Buffer) => output.toString().trim());
|
||||
};
|
||||
|
||||
onRecordingClicked = () => {
|
||||
|
||||
@@ -11,7 +11,10 @@ import fs from 'fs';
|
||||
* Writes a buffer to a specified file path.
|
||||
* Returns a Promise which resolves to the file path.
|
||||
*/
|
||||
export const writeBufferToFile = (filePath: string, buffer: Buffer) => {
|
||||
export const writeBufferToFile = (
|
||||
filePath: string,
|
||||
buffer: Buffer,
|
||||
): Promise<string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.writeFile(filePath, buffer, err => {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user