new look up for adb path

Summary: Look up for the path of the adb may sometimes fail when looking for the folder platform-tools because the adb configuration wasn't done by android studio

Reviewed By: aigoncharov

Differential Revision: D33888687

fbshipit-source-id: 4d0cad2f6b19717e45422632f5d459813a7b7ee0
This commit is contained in:
Andres Orozco Gonzalez
2022-02-03 07:12:52 -08:00
committed by Facebook GitHub Bot
parent f13f7529d3
commit 4b6fcb6aaf

View File

@@ -12,6 +12,7 @@ import {execFile} from 'promisify-child-process';
import adbConfig from './adbConfig';
import adbkit, {Client} from 'adbkit';
import path from 'path';
import {pathExists} from 'fs-extra';
type Config = {
androidHome: string;
@@ -37,7 +38,11 @@ export async function initializeAdbClient(
manually before requesting a client. */
async function createClient(config: Config): Promise<Client> {
const androidHome = config.androidHome;
const adbPath = path.resolve(androidHome, 'platform-tools', 'adb');
let adbPath = path.resolve(androidHome, 'platform-tools', 'adb');
if (!(await pathExists(adbPath))) {
console.info('falling back to the alternative adb path');
adbPath = path.resolve(androidHome, 'adb');
}
return reportPlatformFailures<Client>(
execFile(adbPath, ['start-server']).then(() =>
adbkit.createClient(adbConfig()),