Fix adb path interpolation on Windows
Summary: Concatenating strings is not a great idea for paths. This isn't actually Windows-specific (I think) but maybe more common there. If you have a space as part of your ADB path, you're in for a world of pain. This addressed a couple of issues but I'm sure there are more when you use it for more detailed use cases. Closes https://github.com/facebook/flipper/issues/2438 Reviewed By: mweststrate Differential Revision: D29061367 fbshipit-source-id: 001e498ac42bd8df6e6852be9b42fb5f38379c2e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c52925ce6f
commit
53e612ff6f
@@ -14,7 +14,7 @@ import {createWriteStream} from 'fs';
|
|||||||
import type {LogLevel, DeviceType} from 'flipper-plugin';
|
import type {LogLevel, DeviceType} from 'flipper-plugin';
|
||||||
import which from 'which';
|
import which from 'which';
|
||||||
import {spawn} from 'child_process';
|
import {spawn} from 'child_process';
|
||||||
import {dirname} from 'path';
|
import {dirname, join} from 'path';
|
||||||
import {DeviceSpec} from 'flipper-plugin-lib';
|
import {DeviceSpec} from 'flipper-plugin-lib';
|
||||||
|
|
||||||
const DEVICE_RECORDING_DIR = '/sdcard/flipper_recorder';
|
const DEVICE_RECORDING_DIR = '/sdcard/flipper_recorder';
|
||||||
@@ -262,6 +262,13 @@ export async function launchEmulator(name: string, coldBoot: boolean = false) {
|
|||||||
// On Linux, you must run the emulator from the directory it's in because
|
// On Linux, you must run the emulator from the directory it's in because
|
||||||
// reasons ...
|
// reasons ...
|
||||||
return which('emulator')
|
return which('emulator')
|
||||||
|
.catch(() =>
|
||||||
|
join(
|
||||||
|
process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || '',
|
||||||
|
'tools',
|
||||||
|
'emulator',
|
||||||
|
),
|
||||||
|
)
|
||||||
.then((emulatorPath) => {
|
.then((emulatorPath) => {
|
||||||
if (emulatorPath) {
|
if (emulatorPath) {
|
||||||
const child = spawn(
|
const child = spawn(
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {ServerPorts} from '../reducers/application';
|
|||||||
import {Client as ADBClient} from 'adbkit';
|
import {Client as ADBClient} from 'adbkit';
|
||||||
import {addErrorNotification} from '../reducers/notifications';
|
import {addErrorNotification} from '../reducers/notifications';
|
||||||
import {destroyDevice} from '../reducers/connections';
|
import {destroyDevice} from '../reducers/connections';
|
||||||
|
import {join} from 'path';
|
||||||
|
|
||||||
function createDevice(
|
function createDevice(
|
||||||
adbClient: ADBClient,
|
adbClient: ADBClient,
|
||||||
@@ -140,15 +141,17 @@ export default (store: Store, logger: Logger) => {
|
|||||||
const watchAndroidDevices = () => {
|
const watchAndroidDevices = () => {
|
||||||
// get emulators
|
// get emulators
|
||||||
promisify(which)('emulator')
|
promisify(which)('emulator')
|
||||||
.catch(
|
.catch(() =>
|
||||||
() =>
|
join(
|
||||||
`${
|
process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || '',
|
||||||
process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || ''
|
'tools',
|
||||||
}/tools/emulator`,
|
'emulator',
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.then((emulatorPath) => {
|
.then((emulatorPath) => {
|
||||||
child_process.exec(
|
child_process.execFile(
|
||||||
`${emulatorPath} -list-avds`,
|
emulatorPath as string,
|
||||||
|
['-list-avds'],
|
||||||
(error: Error | null, data: string | null) => {
|
(error: Error | null, data: string | null) => {
|
||||||
if (error != null || data == null) {
|
if (error != null || data == null) {
|
||||||
console.warn('List AVD failed: ', error);
|
console.warn('List AVD failed: ', error);
|
||||||
@@ -161,9 +164,12 @@ export default (store: Store, logger: Logger) => {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.warn('Failed to query AVDs:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
getAdbClient(store)
|
return getAdbClient(store)
|
||||||
.then((client) => {
|
.then((client) => {
|
||||||
client
|
client
|
||||||
.trackDevices()
|
.trackDevices()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {reportPlatformFailures} from './metrics';
|
import {reportPlatformFailures} from './metrics';
|
||||||
import {exec} from 'promisify-child-process';
|
import {execFile} from 'promisify-child-process';
|
||||||
import promiseRetry from 'promise-retry';
|
import promiseRetry from 'promise-retry';
|
||||||
import adbConfig from '../utils/adbConfig';
|
import adbConfig from '../utils/adbConfig';
|
||||||
import adbkit, {Client} from 'adbkit';
|
import adbkit, {Client} from 'adbkit';
|
||||||
@@ -32,7 +32,7 @@ function createClient(store: Store): Promise<Client> {
|
|||||||
const androidHome = store.getState().settingsState.androidHome;
|
const androidHome = store.getState().settingsState.androidHome;
|
||||||
const adbPath = path.resolve(androidHome, 'platform-tools/adb');
|
const adbPath = path.resolve(androidHome, 'platform-tools/adb');
|
||||||
return reportPlatformFailures<Client>(
|
return reportPlatformFailures<Client>(
|
||||||
exec(`${adbPath} start-server`).then(() =>
|
execFile(adbPath, ['start-server']).then(() =>
|
||||||
adbkit.createClient(adbConfig()),
|
adbkit.createClient(adbConfig()),
|
||||||
),
|
),
|
||||||
'createADBClient.shell',
|
'createADBClient.shell',
|
||||||
|
|||||||
@@ -594,5 +594,8 @@
|
|||||||
],
|
],
|
||||||
"raincloud": [
|
"raincloud": [
|
||||||
16
|
16
|
||||||
|
],
|
||||||
|
"app-microsoft-windows-outline": [
|
||||||
|
24
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user