From fac138ded32c32f3ded73d240fb61fb9dfe6baf1 Mon Sep 17 00:00:00 2001 From: John Knox Date: Tue, 5 Mar 2019 10:22:33 -0800 Subject: [PATCH] Use full emulator path when running it Summary: This is required on linux or it isn't found. It's already done elsewhere this way. Reviewed By: passy Differential Revision: D14303606 fbshipit-source-id: 8b3fca776d43076cdc2f814de19b0b381350dcc9 --- src/dispatcher/androidDevice.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/dispatcher/androidDevice.js b/src/dispatcher/androidDevice.js index ce89a9573..cc6286d15 100644 --- a/src/dispatcher/androidDevice.js +++ b/src/dispatcher/androidDevice.js @@ -12,6 +12,8 @@ import type BaseDevice from '../devices/BaseDevice'; import type {Logger} from '../fb-interfaces/Logger.js'; import {registerDeviceCallbackOnPlugins} from '../utils/onRegisterDevice.js'; import {getAdbClient} from '../utils/adbClient'; +import {default as which} from 'which'; +import {promisify} from 'util'; function createDevice( adbClient: any, @@ -62,20 +64,22 @@ function getRunningEmulatorName(id: string): Promise { export default (store: Store, logger: Logger) => { const watchAndroidDevices = () => { // get emulators - child_process.exec( - 'emulator -list-avds', - (error: ?Error, data: ?string) => { - if (error != null || data == null) { - console.error(error || 'Failed to list AVDs'); - return; - } - const payload = data.split('\n').filter(Boolean); - store.dispatch({ - type: 'REGISTER_ANDROID_EMULATORS', - payload, - }); - }, - ); + promisify(which)('emulator').then(emulatorPath => { + child_process.exec( + `${emulatorPath} -list-avds`, + (error: ?Error, data: ?string) => { + if (error != null || data == null) { + console.error(error || 'Failed to list AVDs'); + return; + } + const payload = data.split('\n').filter(Boolean); + store.dispatch({ + type: 'REGISTER_ANDROID_EMULATORS', + payload, + }); + }, + ); + }); getAdbClient() .then(client => {