diff --git a/lib/definitions/livesync.d.ts b/lib/definitions/livesync.d.ts index 639cdcb811..717f41693f 100644 --- a/lib/definitions/livesync.d.ts +++ b/lib/definitions/livesync.d.ts @@ -401,8 +401,8 @@ interface IPlatformLiveSyncService { shouldRestart(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise; getDeviceLiveSyncService(device: Mobile.IDevice, projectData: IProjectData): INativeScriptDeviceLiveSyncService; } -interface IRefreshApplicationInfo { - didRefresh: boolean; +interface IRestartApplicationInfo { + didRestart: boolean; } interface INativeScriptDeviceLiveSyncService { diff --git a/lib/services/livesync/livesync-service.ts b/lib/services/livesync/livesync-service.ts index 1ab42551d7..78da9f69f1 100644 --- a/lib/services/livesync/livesync-service.ts +++ b/lib/services/livesync/livesync-service.ts @@ -152,7 +152,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi } @performanceLog() - private async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string): Promise { + private async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string): Promise { const deviceDescriptor = this.getDeviceDescriptor(liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier, projectData.projectDir); return deviceDescriptor && deviceDescriptor.debugggingEnabled ? @@ -160,22 +160,22 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, debugOpts, outputPath); } - private async refreshApplicationWithoutDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string, settings?: IRefreshApplicationSettings): Promise { - const result = { didRefresh: false }; + private async refreshApplicationWithoutDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string, settings?: IRefreshApplicationSettings): Promise { + const result = { didRestart: false }; const platform = liveSyncResultInfo.deviceAppData.platform; const platformLiveSyncService = this.getLiveSyncService(platform); const applicationIdentifier = projectData.projectIdentifiers[platform.toLowerCase()]; try { let shouldRestart = await platformLiveSyncService.shouldRestart(projectData, liveSyncResultInfo); if (!shouldRestart) { - result.didRefresh = await platformLiveSyncService.tryRefreshApplication(projectData, liveSyncResultInfo); - shouldRestart = !result.didRefresh; + shouldRestart = !await platformLiveSyncService.tryRefreshApplication(projectData, liveSyncResultInfo); } if (shouldRestart) { const deviceIdentifier = liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier; this.emit(DEBUGGER_DETACHED_EVENT_NAME, { deviceIdentifier }); await platformLiveSyncService.restartApplication(projectData, liveSyncResultInfo); + result.didRestart = true; } } catch (err) { this.$logger.info(`Error while trying to start application ${applicationIdentifier} on device ${liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier}. Error is: ${err.message || err}`); @@ -219,7 +219,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi // if we try to send the launch request, the debugger port will not be printed and the command will timeout debugOptions.start = !debugOptions.debugBrk; - debugOptions.forceDebuggerAttachedEvent = !refreshInfo.didRefresh; + debugOptions.forceDebuggerAttachedEvent = refreshInfo.didRestart; const deviceOption = { deviceIdentifier: liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier, debugOptions: debugOptions,