Skip to content

Commit

Permalink
fix(android): fix path issue for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
imhoffd committed Jun 10, 2019
1 parent 4851cbb commit 9b87583
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/android/utils/adb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ADB_GETPROP_MAP: ReadonlyMap<string, keyof MappedDeviceProps> = new Map<st
export async function getDevices(sdk: SDK): Promise<Device[]> {
const debug = Debug(`${modulePrefix}:${getDevices.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['devices', '-l'];
debug('Invoking adb: %O %O', adbBin, args);

Expand Down Expand Up @@ -74,7 +74,7 @@ export async function getDevices(sdk: SDK): Promise<Device[]> {
export async function getDeviceProperty(sdk: SDK, device: Device, property: string): Promise<string> {
const debug = Debug(`${modulePrefix}:${getDeviceProperty.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'shell', 'getprop', property];
debug('Invoking adb: %O %O', adbBin, args);

Expand All @@ -87,7 +87,7 @@ export async function getDeviceProperties(sdk: SDK, device: Device): Promise<Dev
const debug = Debug(`${modulePrefix}:${getDeviceProperties.name}`);
const re = /^\[([a-z0-9\.]+)\]: \[(.*)\]$/;
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'shell', 'getprop'];
debug('Invoking adb: %O %O', adbBin, args);
const propAllowList = [...ADB_GETPROP_MAP.keys()];
Expand All @@ -113,7 +113,7 @@ export async function getDeviceProperties(sdk: SDK, device: Device): Promise<Dev
export async function waitForDevice(sdk: SDK, serial: string): Promise<void> {
const debug = Debug(`${modulePrefix}:${waitForDevice.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', serial, 'wait-for-any-device'];
debug('Invoking adb: %O %O', adbBin, args);

Expand Down Expand Up @@ -141,7 +141,7 @@ export async function waitForBoot(sdk: SDK, device: Device): Promise<void> {
export async function waitForClose(sdk: SDK, device: Device, app: string): Promise<void> {
const debug = Debug(`${modulePrefix}:${waitForClose.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'shell', `ps | grep ${app}`];

return new Promise<void>(resolve => {
Expand All @@ -163,7 +163,7 @@ export async function waitForClose(sdk: SDK, device: Device, app: string): Promi
export async function installApk(sdk: SDK, device: Device, apk: string): Promise<void> {
const debug = Debug(`${modulePrefix}:${installApk.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'install', '-r', '-t', apk];
debug('Invoking adb: %O %O', adbBin, args);

Expand Down Expand Up @@ -203,7 +203,7 @@ export async function installApk(sdk: SDK, device: Device, apk: string): Promise
export async function closeApp(sdk: SDK, device: Device, app: string): Promise<void> {
const debug = Debug(`${modulePrefix}:${closeApp.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'shell', 'am', 'force-stop', app];
debug('Invoking adb: %O %O', adbBin, args);

Expand All @@ -213,7 +213,7 @@ export async function closeApp(sdk: SDK, device: Device, app: string): Promise<v
export async function uninstallApp(sdk: SDK, device: Device, app: string): Promise<void> {
const debug = Debug(`${modulePrefix}:${uninstallApp.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'uninstall', app];
debug('Invoking adb: %O %O', adbBin, args);

Expand Down Expand Up @@ -245,7 +245,7 @@ export function parseAdbInstallOutput(line: string): ADBEvent | undefined {
export async function startActivity(sdk: SDK, device: Device, packageName: string, activityName: string): Promise<void> {
const debug = Debug(`${modulePrefix}:${startActivity.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'shell', 'am', 'start', '-W', '-n', `${packageName}/${activityName}`];
debug('Invoking adb: %O %O', adbBin, args);

Expand Down Expand Up @@ -308,7 +308,7 @@ export function parseAdbDevices(output: string): Device[] {
export async function forwardPorts(sdk: SDK, device: Device, ports: Ports): Promise<void> {
const debug = Debug(`${modulePrefix}:${forwardPorts.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'reverse', `tcp:${ports.device}`, `tcp:${ports.host}`];
debug('Invoking adb: %O %O', adbBin, args);

Expand All @@ -318,7 +318,7 @@ export async function forwardPorts(sdk: SDK, device: Device, ports: Ports): Prom
export async function unforwardPorts(sdk: SDK, device: Device, ports: Ports): Promise<void> {
const debug = Debug(`${modulePrefix}:${forwardPorts.name}`);
const platformTools = await getSDKPackage(path.join(sdk.root, 'platform-tools'));
const adbBin = `${platformTools.location}/adb`;
const adbBin = path.join(platformTools.location, 'adb');
const args = ['-s', device.serial, 'reverse', '--remove', `tcp:${ports.device}`];
debug('Invoking adb: %O %O', adbBin, args);

Expand Down
2 changes: 1 addition & 1 deletion src/android/utils/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function runEmulator(sdk: SDK, avd: AVD, port: number): Promise<Dev
export async function spawnEmulator(sdk: SDK, avd: AVD, port: number): Promise<void> {
const debug = Debug(`${modulePrefix}:${spawnEmulator.name}`);
const emulator = await getSDKPackage(path.join(sdk.root, 'emulator'));
const emulatorBin = `${emulator.location}/emulator`;
const emulatorBin = path.join(emulator.location, 'emulator');
const args = ['-avd', avd.id, '-port', port.toString(), '-verbose'];
debug('Invoking emulator: %O %O', emulatorBin, args);

Expand Down

0 comments on commit 9b87583

Please sign in to comment.