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:
committed by
Facebook GitHub Bot
parent
f13f7529d3
commit
4b6fcb6aaf
@@ -12,6 +12,7 @@ import {execFile} from 'promisify-child-process';
|
|||||||
import adbConfig from './adbConfig';
|
import adbConfig from './adbConfig';
|
||||||
import adbkit, {Client} from 'adbkit';
|
import adbkit, {Client} from 'adbkit';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import {pathExists} from 'fs-extra';
|
||||||
|
|
||||||
type Config = {
|
type Config = {
|
||||||
androidHome: string;
|
androidHome: string;
|
||||||
@@ -37,7 +38,11 @@ export async function initializeAdbClient(
|
|||||||
manually before requesting a client. */
|
manually before requesting a client. */
|
||||||
async function createClient(config: Config): Promise<Client> {
|
async function createClient(config: Config): Promise<Client> {
|
||||||
const androidHome = config.androidHome;
|
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>(
|
return reportPlatformFailures<Client>(
|
||||||
execFile(adbPath, ['start-server']).then(() =>
|
execFile(adbPath, ['start-server']).then(() =>
|
||||||
adbkit.createClient(adbConfig()),
|
adbkit.createClient(adbConfig()),
|
||||||
|
|||||||
Reference in New Issue
Block a user