Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move device discovery to debug command as it is done for run command #3008

Merged
merged 2 commits into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 6 additions & 2 deletions lib/services/livesync/livesync-command-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @param liveSyncService Service expected to do the actual livesyncing
* @param platform The platform for which the livesync will be ran
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDocs are more applicable for the interface (ILiveSyncCommandHelper) as we are calling the method through it. In order to have autocomplete and JSDocs when using the injected dependency ("liveSyncCommandHelper"), the JSDocs must be in the interface itself.

Also you have to define the return type of the method:

* @returns {Promise<void>}

public async executeLiveSyncOperation(devices: Mobile.IDevice[], liveSyncService: ILiveSyncService, platform: string): Promise<void> {
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) {
Expand Down