@@ -156,20 +156,21 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
156
156
}
157
157
}
158
158
159
- private async refreshApplication ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , debugOpts ?: IDebugOptions , outputPath ?: string ) : Promise < void | IDebugInformation > {
159
+ private async refreshApplication ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , debugOpts ?: IDebugOptions , outputPath ?: string ) : Promise < IRefreshApplicationInfo | IDebugInformation > {
160
160
const deviceDescriptor = this . getDeviceDescriptor ( liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier , projectData . projectDir ) ;
161
161
162
162
return deviceDescriptor && deviceDescriptor . debugggingEnabled ?
163
163
this . refreshApplicationWithDebug ( projectData , liveSyncResultInfo , debugOpts , outputPath ) :
164
164
this . refreshApplicationWithoutDebug ( projectData , liveSyncResultInfo , debugOpts , outputPath ) ;
165
165
}
166
166
167
- private async refreshApplicationWithoutDebug ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , debugOpts ?: IDebugOptions , outputPath ?: string , settings ?: IShouldSkipEmitLiveSyncNotification ) : Promise < void > {
167
+ private async refreshApplicationWithoutDebug ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , debugOpts ?: IDebugOptions , outputPath ?: string , settings ?: IShouldSkipEmitLiveSyncNotification ) : Promise < IRefreshApplicationInfo > {
168
+ let result : IRefreshApplicationInfo = { didRestart : false } ;
168
169
const platform = liveSyncResultInfo . deviceAppData . platform ;
169
170
const platformLiveSyncService = this . getLiveSyncService ( platform ) ;
170
171
const applicationIdentifier = projectData . projectIdentifiers [ platform . toLowerCase ( ) ] ;
171
172
try {
172
- await platformLiveSyncService . refreshApplication ( projectData , liveSyncResultInfo ) ;
173
+ result = await platformLiveSyncService . refreshApplication ( projectData , liveSyncResultInfo ) ;
173
174
} catch ( err ) {
174
175
this . $logger . info ( `Error while trying to start application ${ applicationIdentifier } on device ${ liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier } . Error is: ${ err . message || err } ` ) ;
175
176
const msg = `Unable to start application ${ applicationIdentifier } on device ${ liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier } . Try starting it manually.` ;
@@ -193,12 +194,14 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
193
194
deviceIdentifier : liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier ,
194
195
isFullSync : liveSyncResultInfo . isFullSync
195
196
} ) ;
197
+
198
+ return result ;
196
199
}
197
200
198
201
private async refreshApplicationWithDebug ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , debugOptions : IDebugOptions , outputPath ?: string ) : Promise < IDebugInformation > {
202
+ let didRestart = false ;
199
203
const deviceAppData = liveSyncResultInfo . deviceAppData ;
200
204
debugOptions = debugOptions || { } ;
201
-
202
205
const deviceIdentifier = liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier ;
203
206
if ( debugOptions . debugBrk ) {
204
207
await this . $debugService . debugStop ( deviceIdentifier ) ;
@@ -211,13 +214,15 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
211
214
this . handleDeveloperDiskImageError ( err , liveSyncResultInfo , projectData , debugOptions , outputPath ) ;
212
215
}
213
216
} else {
214
- await this . refreshApplicationWithoutDebug ( projectData , liveSyncResultInfo , debugOptions , outputPath , { shouldSkipEmitLiveSyncNotification : true } ) ;
217
+ const refreshInfo = await this . refreshApplicationWithoutDebug ( projectData , liveSyncResultInfo , debugOptions , outputPath , { shouldSkipEmitLiveSyncNotification : true } ) ;
218
+ didRestart = refreshInfo . didRestart ;
215
219
}
216
220
217
221
// we do not stop the application when debugBrk is false, so we need to attach, instead of launch
218
222
// if we try to send the launch request, the debugger port will not be printed and the command will timeout
219
223
debugOptions . start = ! debugOptions . debugBrk ;
220
224
225
+ debugOptions . forceDebuggerAttachedEvent = didRestart ;
221
226
const deviceOption = {
222
227
deviceIdentifier : liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier ,
223
228
debugOptions : debugOptions ,
@@ -269,13 +274,17 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
269
274
debugData . pathToAppPackage = this . $platformService . lastOutputPath ( settings . platform , buildConfig , projectData , settings . outputPath ) ;
270
275
271
276
const debugInfo = await this . $debugService . debug ( debugData , settings . debugOptions ) ;
272
- const result = this . printDebugInformation ( debugInfo ) ;
277
+ const fireDebuggerAttachedEvent = settings . debugOptions . forceDebuggerAttachedEvent || debugInfo . hasReconnected ;
278
+ const result = this . printDebugInformation ( debugInfo , fireDebuggerAttachedEvent ) ;
273
279
return result ;
274
280
}
275
281
276
- public printDebugInformation ( debugInformation : IDebugInformation ) : IDebugInformation {
282
+ public printDebugInformation ( debugInformation : IDebugInformation , fireDebuggerAttachedEvent : boolean = true ) : IDebugInformation {
277
283
if ( ! ! debugInformation . url ) {
278
- this . emit ( DEBUGGER_ATTACHED_EVENT_NAME , debugInformation ) ;
284
+ if ( fireDebuggerAttachedEvent ) {
285
+ this . emit ( DEBUGGER_ATTACHED_EVENT_NAME , debugInformation ) ;
286
+ }
287
+
279
288
this . $logger . info ( `To start debugging, open the following URL in Chrome:${ EOL } ${ debugInformation . url } ${ EOL } ` . cyan ) ;
280
289
}
281
290
0 commit comments