From 8e705c08c73d38dbecd6b458017e4c8691e1d2d9 Mon Sep 17 00:00:00 2001 From: Frieder Bluemle Date: Thu, 9 Apr 2020 17:29:04 -0700 Subject: [PATCH] Add support for ANDROID_SDK_ROOT --- src/android/adb.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/android/adb.ts b/src/android/adb.ts index 6339014..d154788 100644 --- a/src/android/adb.ts +++ b/src/android/adb.ts @@ -13,14 +13,16 @@ export function runAndroidLoggingProcess(adbPath?: string): ChildProcess { return spawnLogcatProcess(execPath); } +export function getSdkRoot(): string | undefined { + return process.env.ANDROID_SDK_ROOT ?? process.env.ANDROID_HOME; +} + export function getAdbPath(customPath?: string): string { if (customPath) { return path.resolve(customPath); } - - return process.env.ANDROID_HOME - ? `${process.env.ANDROID_HOME}/platform-tools/adb` - : 'adb'; + const sdkRoot = getSdkRoot(); + return sdkRoot ? `${sdkRoot}/platform-tools/adb` : 'adb'; } export function spawnLogcatProcess(adbPath: string): ChildProcess {