Skip to content

Commit 464cf5c

Browse files
committed
Raise debuggerAttached only if app is restarted
1 parent 33e5862 commit 464cf5c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/definitions/livesync.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ interface IPlatformLiveSyncService {
401401
shouldRestart(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<boolean>;
402402
getDeviceLiveSyncService(device: Mobile.IDevice, projectData: IProjectData): INativeScriptDeviceLiveSyncService;
403403
}
404-
interface IRefreshApplicationInfo {
405-
didRefresh: boolean;
404+
interface IRestartApplicationInfo {
405+
didRestart: boolean;
406406
}
407407

408408
interface INativeScriptDeviceLiveSyncService {

lib/services/livesync/livesync-service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -152,30 +152,30 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
152152
}
153153

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

158158
return deviceDescriptor && deviceDescriptor.debugggingEnabled ?
159159
this.refreshApplicationWithDebug(projectData, liveSyncResultInfo, debugOpts, outputPath) :
160160
this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, debugOpts, outputPath);
161161
}
162162

163-
private async refreshApplicationWithoutDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string, settings?: IRefreshApplicationSettings): Promise<IRefreshApplicationInfo> {
164-
const result = { didRefresh: false };
163+
private async refreshApplicationWithoutDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string, settings?: IRefreshApplicationSettings): Promise<IRestartApplicationInfo> {
164+
const result = { didRestart: false };
165165
const platform = liveSyncResultInfo.deviceAppData.platform;
166166
const platformLiveSyncService = this.getLiveSyncService(platform);
167167
const applicationIdentifier = projectData.projectIdentifiers[platform.toLowerCase()];
168168
try {
169169
let shouldRestart = await platformLiveSyncService.shouldRestart(projectData, liveSyncResultInfo);
170170
if (!shouldRestart) {
171-
result.didRefresh = await platformLiveSyncService.tryRefreshApplication(projectData, liveSyncResultInfo);
172-
shouldRestart = !result.didRefresh;
171+
shouldRestart = !await platformLiveSyncService.tryRefreshApplication(projectData, liveSyncResultInfo);
173172
}
174173

175174
if (shouldRestart) {
176175
const deviceIdentifier = liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier;
177176
this.emit(DEBUGGER_DETACHED_EVENT_NAME, { deviceIdentifier });
178177
await platformLiveSyncService.restartApplication(projectData, liveSyncResultInfo);
178+
result.didRestart = true;
179179
}
180180
} catch (err) {
181181
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
219219
// if we try to send the launch request, the debugger port will not be printed and the command will timeout
220220
debugOptions.start = !debugOptions.debugBrk;
221221

222-
debugOptions.forceDebuggerAttachedEvent = !refreshInfo.didRefresh;
222+
debugOptions.forceDebuggerAttachedEvent = refreshInfo.didRestart;
223223
const deviceOption = {
224224
deviceIdentifier: liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier,
225225
debugOptions: debugOptions,

0 commit comments

Comments
 (0)