Extract temp path util

Summary:
`electron.remote` access is slow so we can cache this
like we do in other places. Also means one fewer `electron`
import which is gonna add up for Flipper Decap.

Reviewed By: mweststrate

Differential Revision: D30247431

fbshipit-source-id: 90f0e8df99af8bed40fbebcfd445abaca2965b7c
This commit is contained in:
Pascal Hartig
2021-08-11 11:02:10 -07:00
committed by Facebook GitHub Bot
parent 11c1c39bdc
commit 4e17fb9c48
2 changed files with 16 additions and 3 deletions

View File

@@ -12,7 +12,6 @@ import child_process, {ChildProcess} from 'child_process';
import BaseDevice from './BaseDevice';
import JSONStream from 'JSONStream';
import {Transform} from 'stream';
import electron from 'electron';
import fs from 'fs';
import {v1 as uuid} from 'uuid';
import path from 'path';
@@ -21,6 +20,7 @@ import {exec} from 'child_process';
import {default as promiseTimeout} from '../utils/promiseTimeout';
import {IOSBridge} from '../utils/IOSBridge';
import split2 from 'split2';
import {getAppTempPath} from '../utils/pathUtils';
type IOSLogLevel = 'Default' | 'Info' | 'Debug' | 'Error' | 'Fault';
@@ -69,7 +69,7 @@ export default class IOSDevice extends BaseDevice {
return Buffer.from([]);
}
const tmpImageName = uuid() + '.png';
const tmpDirectory = (electron.app || electron.remote.app).getPath('temp');
const tmpDirectory = getAppTempPath();
const tmpFilePath = path.join(tmpDirectory, tmpImageName);
const command =
this.deviceType === 'emulator'