@@ -37,14 +37,15 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
37
37
public sync ( platform : string , appIdentifier : string , localProjectRootPath : string , projectFilesPath : string , excludedProjectDirsAndFiles : string [ ] , watchGlob : any ,
38
38
restartAppOnDeviceAction : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) => IFuture < void > ,
39
39
notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ,
40
- beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ) : IFuture < void > {
40
+ beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ,
41
+ canLiveSyncAction ?: ( device : Mobile . IDevice , appIdentifier : string ) => IFuture < boolean > ) : IFuture < void > {
41
42
return ( ( ) => {
42
43
if ( ! this . _initialized ) {
43
44
this . initialize ( platform ) . wait ( ) ;
44
45
}
45
46
46
47
let projectFiles = this . $fs . enumerateFilesInDirectorySync ( projectFilesPath , ( filePath , stat ) => ! this . isFileExcluded ( path . relative ( projectFilesPath , filePath ) , excludedProjectDirsAndFiles , projectFilesPath ) , { enumerateDirectories : true } ) ;
47
- this . syncCore ( projectFiles , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction ) . wait ( ) ;
48
+ this . syncCore ( projectFiles , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , canLiveSyncAction ) . wait ( ) ;
48
49
49
50
if ( this . $options . watch ) {
50
51
let __this = this ;
@@ -64,7 +65,8 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
64
65
65
66
private syncCore ( projectFiles : string [ ] , appIdentifier : string , localProjectRootPath : string ,
66
67
restartAppOnDeviceAction : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) => IFuture < void > ,
67
- notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ) : IFuture < void > {
68
+ notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ,
69
+ canLiveSyncAction : ( device : Mobile . IDevice , appIdentifier : string ) => IFuture < boolean > ) : IFuture < void > {
68
70
return ( ( ) => {
69
71
let deviceAppData = this . $deviceAppDataFactory . create ( appIdentifier , this . $devicesServices . platform ) ;
70
72
let localToDevicePaths = _ ( projectFiles )
@@ -83,13 +85,17 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
83
85
return ;
84
86
}
85
87
88
+ if ( canLiveSyncAction && ! canLiveSyncAction ( device , appIdentifier ) . wait ( ) ) {
89
+ return ;
90
+ }
91
+
86
92
this . $logger . info ( "Transfering project files..." ) ;
87
93
device . fileSystem . transferFiles ( deviceAppData . appIdentifier , localToDevicePaths ) . wait ( ) ;
88
94
this . $logger . info ( "Successfully transfered all project files." ) ;
89
95
90
96
this . $logger . info ( "Applying changes..." ) ;
91
97
restartAppOnDeviceAction ( device , deviceAppData , localToDevicePaths ) . wait ( ) ;
92
- this . $logger . info ( `Successfully synced application ${ deviceAppData . appIdentifier } .` ) ;
98
+ this . $logger . info ( `Successfully synced application ${ deviceAppData . appIdentifier } on device ${ device . deviceInfo . identifier } .` ) ;
93
99
}
94
100
} ) . future < void > ( ) ( ) ;
95
101
}
@@ -103,7 +109,8 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
103
109
private batchLiveSync ( filePath : string , appIdentifier : string , localProjectRootPath : string ,
104
110
restartAppOnDeviceAction : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) => IFuture < void > ,
105
111
notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ,
106
- beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ) : void {
112
+ beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ,
113
+ canLiveSyncAction ?: ( device : Mobile . IDevice , appIdentifier : string ) => IFuture < boolean > ) : void {
107
114
if ( ! this . timer ) {
108
115
this . timer = setInterval ( ( ) => {
109
116
let filesToSync = this . syncQueue ;
@@ -112,7 +119,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
112
119
this . $logger . trace ( "Syncing %s" , filesToSync . join ( ", " ) ) ;
113
120
this . $dispatcher . dispatch ( ( ) => {
114
121
return ( ( ) => {
115
- this . syncCore ( filesToSync , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction ) . wait ( ) ;
122
+ this . syncCore ( filesToSync , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , canLiveSyncAction ) . wait ( ) ;
116
123
} ) . future < void > ( ) ( ) ;
117
124
} ) ;
118
125
}
0 commit comments