From fe6813042ce5afd7424dbd73aa20f91fdabae8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Wed, 11 Sep 2019 03:01:18 -0700 Subject: [PATCH] DevicesButton Summary: _typescript_ Reviewed By: jknoxville Differential Revision: D17284473 fbshipit-source-id: 2a0586dc3147338c8335eadb4dcbe158e8f1dc97 --- src/chrome/DevicesButton.tsx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/chrome/DevicesButton.tsx b/src/chrome/DevicesButton.tsx index cf778e2ff..bf9185cae 100644 --- a/src/chrome/DevicesButton.tsx +++ b/src/chrome/DevicesButton.tsx @@ -48,15 +48,19 @@ class DevicesButton extends Component { // reasons ... whichPromise('emulator') .catch(() => `${process.env.ANDROID_HOME || ''}/tools/emulator`) - .then((emulatorPath: string) => { - const child = spawn(emulatorPath, [`@${name}`], { - detached: true, - cwd: dirname(emulatorPath), - }); - child.stderr.on('data', data => { - console.error(`Android emulator error: ${data}`); - }); - child.on('error', console.error); + .then(emulatorPath => { + if (emulatorPath) { + const child = spawn(emulatorPath, [`@${name}`], { + detached: true, + cwd: dirname(emulatorPath), + }); + child.stderr.on('data', data => { + console.error(`Android emulator error: ${data}`); + }); + child.on('error', console.error); + } else { + throw new Error('Could not get emulator path'); + } }) .catch(console.error); this.props.preferDevice(name); @@ -155,7 +159,7 @@ class DevicesButton extends Component { })); if (emulators.length > 0) { dropdown.push( - {type: 'separator'}, + {type: 'separator' as 'separator'}, { label: 'Launch Android emulators', enabled: false, @@ -165,7 +169,7 @@ class DevicesButton extends Component { } } if (dropdown.length > 0) { - dropdown.push({type: 'separator'}); + dropdown.push({type: 'separator' as 'separator'}); } dropdown.push({ label: 'Open File...',