@@ -51,6 +51,17 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
51
51
const liveSyncProcessInfo = this . liveSyncProcessesInfo [ projectDir ] ;
52
52
53
53
if ( liveSyncProcessInfo ) {
54
+ const projectData = this . $projectDataService . getProjectData ( projectDir ) ;
55
+
56
+ if ( liveSyncProcessInfo . syncToPreviewApp ) {
57
+ await this . $hooksService . executeAfterHooks ( 'watch' , {
58
+ hookArgs : {
59
+ projectData
60
+ }
61
+ } ) ;
62
+ await this . $previewAppLiveSyncService . stopLiveSync ( ) ;
63
+ }
64
+
54
65
// In case we are coming from error during livesync, the current action is the one that erred (but we are still executing it),
55
66
// so we cannot await it as this will cause infinite loop.
56
67
const shouldAwaitPendingOperation = ! stopOptions || stopOptions . shouldAwaitAllActions ;
@@ -80,7 +91,6 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
80
91
liveSyncProcessInfo . deviceDescriptors = [ ] ;
81
92
82
93
// Kill typescript watcher
83
- const projectData = this . $projectDataService . getProjectData ( projectDir ) ;
84
94
await this . $hooksService . executeAfterHooks ( 'watch' , {
85
95
hookArgs : {
86
96
projectData
@@ -350,6 +360,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
350
360
this . liveSyncProcessesInfo [ projectDir ] . actionsChain = this . liveSyncProcessesInfo [ projectDir ] . actionsChain || Promise . resolve ( ) ;
351
361
this . liveSyncProcessesInfo [ projectDir ] . currentSyncAction = this . liveSyncProcessesInfo [ projectDir ] . actionsChain ;
352
362
this . liveSyncProcessesInfo [ projectDir ] . isStopped = false ;
363
+ this . liveSyncProcessesInfo [ projectDir ] . syncToPreviewApp = liveSyncData . syncToPreviewApp ;
353
364
354
365
const currentDeviceDescriptors = this . getLiveSyncDeviceDescriptors ( projectDir ) ;
355
366
this . liveSyncProcessesInfo [ projectDir ] . deviceDescriptors = _ . uniqBy ( currentDeviceDescriptors . concat ( deviceDescriptors ) , deviceDescriptorPrimaryKey ) ;
@@ -744,13 +755,6 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
744
755
this . liveSyncProcessesInfo [ liveSyncData . projectDir ] . timer = timeoutTimer ;
745
756
746
757
this . $processService . attachToProcessExitSignals ( this , ( ) => {
747
- if ( liveSyncData . syncToPreviewApp ) {
748
- // Do not await here, we are in process exit's handler.
749
- /* tslint:disable:no-floating-promises */
750
- this . $previewAppLiveSyncService . stopLiveSync ( ) ;
751
- /* tslint:enable:no-floating-promises */
752
- }
753
-
754
758
_ . keys ( this . liveSyncProcessesInfo ) . forEach ( projectDir => {
755
759
// Do not await here, we are in process exit's handler.
756
760
/* tslint:disable:no-floating-promises */
0 commit comments