Skip to content

Commit aab4d49

Browse files
committed
Cleanly handle missing ADB in ADB interceptor
1 parent 5320f4e commit aab4d49

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/interceptors/android/adb-commands.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as stream from 'stream';
22
import * as path from 'path';
33
import * as adb from 'adbkit';
44

5+
import { reportError } from '../../error-tracking';
6+
57
export const ANDROID_TEMP = '/data/local/tmp';
68
export const SYSTEM_CA_PATH = '/system/etc/security/cacerts';
79

@@ -15,10 +17,18 @@ export function createAdbClient() {
1517
}
1618

1719
export async function getConnectedDevices(adbClient: adb.AdbClient) {
18-
const devices = await adbClient.listDevices();
19-
return devices
20-
.filter(d => d.type !== 'offline')
21-
.map(d => d.id);
20+
try {
21+
const devices = await adbClient.listDevices();
22+
return devices
23+
.filter(d => d.type !== 'offline')
24+
.map(d => d.id);
25+
} catch (e) {
26+
if (e.code === 'ENOENT') return [];
27+
else {
28+
reportError(e);
29+
throw e;
30+
}
31+
}
2232
}
2333

2434
export function stringAsStream(input: string) {

0 commit comments

Comments
 (0)