Add option to cold boot emulators

Summary: This is useful when your emulator freezes.

Reviewed By: mweststrate

Differential Revision: D25998579

fbshipit-source-id: 236c16c3008f0e33d62e4c486b5a04383b1a59ba
This commit is contained in:
John Knox
2021-01-25 08:55:03 -08:00
committed by Facebook GitHub Bot
parent d77940a839
commit 3e911c8288
3 changed files with 55 additions and 24 deletions

View File

@@ -202,16 +202,20 @@ export default class AndroidDevice extends BaseDevice {
}
}
export async function launchEmulator(name: string) {
export async function launchEmulator(name: string, coldBoot: boolean = false) {
// On Linux, you must run the emulator from the directory it's in because
// reasons ...
return which('emulator')
.then((emulatorPath) => {
if (emulatorPath) {
const child = spawn(emulatorPath, [`@${name}`], {
detached: true,
cwd: dirname(emulatorPath),
});
const child = spawn(
emulatorPath,
[`@${name}`, ...(coldBoot ? ['-no-snapshot-load'] : [])],
{
detached: true,
cwd: dirname(emulatorPath),
},
);
child.stderr.on('data', (data) => {
console.error(`Android emulator error: ${data}`);
});