From d6e64a45728c67966a7b15ef3e8a18612f789f62 Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Wed, 26 Jul 2017 18:14:05 +0300 Subject: [PATCH 1/2] move device discovery to debug command as it is done for run command --- lib/commands/debug.ts | 2 ++ lib/services/livesync/livesync-command-helper.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/commands/debug.ts b/lib/commands/debug.ts index 54f947de7e..b0322844f6 100644 --- a/lib/commands/debug.ts +++ b/lib/commands/debug.ts @@ -37,6 +37,8 @@ export class DebugPlatformCommand implements ICommand { const selectedDeviceForDebug = await this.getDeviceForDebug(); + await this.$devicesService.detectCurrentlyAttachedDevices({ shouldReturnImmediateResult: false, platform: this.platform }); + await this.$liveSyncCommandHelper.executeLiveSyncOperation([selectedDeviceForDebug], this.$debugLiveSyncService, this.platform); } diff --git a/lib/services/livesync/livesync-command-helper.ts b/lib/services/livesync/livesync-command-helper.ts index c896d6d478..4326696867 100644 --- a/lib/services/livesync/livesync-command-helper.ts +++ b/lib/services/livesync/livesync-command-helper.ts @@ -15,13 +15,17 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper { return availablePlatforms; } + /** + * Method sets up configuration, before calling livesync and expects that devices are already discovered. + * @param devices List of discovered devices + * @param liveSyncService Service expected to do the actual livesyncing + * @param platform The platform for which the livesync will be ran + */ public async executeLiveSyncOperation(devices: Mobile.IDevice[], liveSyncService: ILiveSyncService, platform: string): Promise { if (!devices || !devices.length) { this.$errors.failWithoutHelp("Unable to find applicable devices to execute operation and unable to start emulator when platform is not specified."); } - await this.$devicesService.detectCurrentlyAttachedDevices({ shouldReturnImmediateResult: false, platform }); - const workingWithiOSDevices = !platform || this.$mobileHelper.isiOSPlatform(platform); const shouldKeepProcessAlive = this.$options.watch || !this.$options.justlaunch; if (workingWithiOSDevices && shouldKeepProcessAlive) { From f1c0673d3753c5d0212eac685c2bcbd9a57f6690 Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Thu, 27 Jul 2017 11:16:23 +0300 Subject: [PATCH 2/2] update after review --- lib/definitions/livesync.d.ts | 7 +++++++ lib/services/livesync/livesync-command-helper.ts | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/definitions/livesync.d.ts b/lib/definitions/livesync.d.ts index 11dea74d7e..5e903fabc0 100644 --- a/lib/definitions/livesync.d.ts +++ b/lib/definitions/livesync.d.ts @@ -256,6 +256,13 @@ interface IDevicePathProvider { } interface ILiveSyncCommandHelper { + /** + * Method sets up configuration, before calling livesync and expects that devices are already discovered. + * @param {Mobile.IDevice[]} devices List of discovered devices + * @param {ILiveSyncService} liveSyncService Service expected to do the actual livesyncing + * @param {string} platform The platform for which the livesync will be ran + * @returns {Promise} + */ executeLiveSyncOperation(devices: Mobile.IDevice[], liveSyncService: ILiveSyncService, platform: string): Promise; getPlatformsForOperation(platform: string): string[]; } diff --git a/lib/services/livesync/livesync-command-helper.ts b/lib/services/livesync/livesync-command-helper.ts index 4326696867..b1854e4e7a 100644 --- a/lib/services/livesync/livesync-command-helper.ts +++ b/lib/services/livesync/livesync-command-helper.ts @@ -15,12 +15,6 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper { return availablePlatforms; } - /** - * Method sets up configuration, before calling livesync and expects that devices are already discovered. - * @param devices List of discovered devices - * @param liveSyncService Service expected to do the actual livesyncing - * @param platform The platform for which the livesync will be ran - */ public async executeLiveSyncOperation(devices: Mobile.IDevice[], liveSyncService: ILiveSyncService, platform: string): Promise { if (!devices || !devices.length) { this.$errors.failWithoutHelp("Unable to find applicable devices to execute operation and unable to start emulator when platform is not specified.");