Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions lib/definitions/livesync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ interface IPlatformLiveSyncService {
shouldRestart(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<boolean>;
getDeviceLiveSyncService(device: Mobile.IDevice, projectData: IProjectData): INativeScriptDeviceLiveSyncService;
}
interface IRefreshApplicationInfo {
didRefresh: boolean;
interface IRestartApplicationInfo {
didRestart: boolean;
}

interface INativeScriptDeviceLiveSyncService {
Expand Down
12 changes: 6 additions & 6 deletions lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,30 +152,30 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
}

@performanceLog()
private async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string): Promise<IRefreshApplicationInfo | IDebugInformation> {
private async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string): Promise<IRestartApplicationInfo | IDebugInformation> {
const deviceDescriptor = this.getDeviceDescriptor(liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier, projectData.projectDir);

return deviceDescriptor && deviceDescriptor.debugggingEnabled ?
this.refreshApplicationWithDebug(projectData, liveSyncResultInfo, debugOpts, outputPath) :
this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, debugOpts, outputPath);
}

private async refreshApplicationWithoutDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string, settings?: IRefreshApplicationSettings): Promise<IRefreshApplicationInfo> {
const result = { didRefresh: false };
private async refreshApplicationWithoutDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string, settings?: IRefreshApplicationSettings): Promise<IRestartApplicationInfo> {
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}`);
Expand Down Expand Up @@ -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,
Expand Down