@@ -34,18 +34,18 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
34
34
} ) . future < string > ( ) ( ) ;
35
35
}
36
36
37
- public sync ( platform : string , appIdentifier : string , localProjectRootPath : string , projectFilesPath : string , excludedProjectDirsAndFiles : string [ ] , watchGlob : any ,
37
+ public sync ( platform : string , appIdentifier : 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 > ,
41
- canLiveSyncAction ?: ( device : Mobile . IDevice , appIdentifier : string ) => IFuture < boolean > ) : IFuture < void > {
40
+ beforeLiveSyncAction ?: ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) => IFuture < void > ,
41
+ beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ) : IFuture < void > {
42
42
return ( ( ) => {
43
43
if ( ! this . _initialized ) {
44
44
this . initialize ( platform ) . wait ( ) ;
45
45
}
46
46
47
47
let projectFiles = this . $fs . enumerateFilesInDirectorySync ( projectFilesPath , ( filePath , stat ) => ! this . isFileExcluded ( path . relative ( projectFilesPath , filePath ) , excludedProjectDirsAndFiles , projectFilesPath ) , { enumerateDirectories : true } ) ;
48
- this . syncCore ( projectFiles , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , canLiveSyncAction ) . wait ( ) ;
48
+ this . syncCore ( projectFiles , appIdentifier , projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction ) . wait ( ) ;
49
49
50
50
if ( this . $options . watch ) {
51
51
let __this = this ;
@@ -54,7 +54,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
54
54
this . on ( 'all' , ( event : string , filePath : string ) => {
55
55
if ( event === "added" || event === "changed" ) {
56
56
if ( ! _ . contains ( excludedProjectDirsAndFiles , filePath ) ) {
57
- __this . batchLiveSync ( filePath , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeBatchLiveSyncAction ) ;
57
+ __this . batchLiveSync ( filePath , appIdentifier , projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeLiveSyncAction , beforeBatchLiveSyncAction ) ;
58
58
}
59
59
}
60
60
} ) ;
@@ -65,32 +65,33 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
65
65
} ) . future < void > ( ) ( ) ;
66
66
}
67
67
68
- private syncCore ( projectFiles : string [ ] , appIdentifier : string , localProjectRootPath : string ,
68
+ private syncCore ( projectFiles : string [ ] , appIdentifier : string , projectFilesPath : string ,
69
69
restartAppOnDeviceAction : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) => IFuture < void > ,
70
70
notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ,
71
- canLiveSyncAction : ( device : Mobile . IDevice , appIdentifier : string ) => IFuture < boolean > ) : IFuture < void > {
71
+ beforeLiveSyncAction ? : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) => IFuture < void > ) : IFuture < void > {
72
72
return ( ( ) => {
73
73
let deviceAppData = this . $deviceAppDataFactory . create ( appIdentifier , this . $devicesServices . platform ) ;
74
74
let localToDevicePaths = _ ( projectFiles )
75
75
. map ( projectFile => this . getProjectFileInfo ( projectFile ) )
76
76
. filter ( projectFileInfo => projectFileInfo . shouldIncludeFile )
77
- . map ( projectFileInfo => this . $localToDevicePathDataFactory . create ( projectFileInfo . fileName , localProjectRootPath , projectFileInfo . onDeviceName , deviceAppData . deviceProjectRootPath ) )
77
+ . map ( projectFileInfo => this . $localToDevicePathDataFactory . create ( projectFileInfo . fileName , projectFilesPath , projectFileInfo . onDeviceName , deviceAppData . deviceProjectRootPath ) )
78
78
. value ( ) ;
79
79
80
80
let action = ( device : Mobile . IDevice ) => {
81
81
return ( ( ) => {
82
82
if ( deviceAppData . isLiveSyncSupported ( device ) . wait ( ) ) {
83
+
84
+ if ( beforeLiveSyncAction ) {
85
+ beforeLiveSyncAction ( device , deviceAppData ) . wait ( ) ;
86
+ }
87
+
83
88
let applications = device . applicationManager . getInstalledApplications ( ) . wait ( ) ;
84
89
if ( ! _ . contains ( applications , deviceAppData . appIdentifier ) ) {
85
90
this . $logger . warn ( `The application with id "${ deviceAppData . appIdentifier } " is not installed on the device yet.` ) ;
86
91
notInstalledAppOnDeviceAction ( device ) . wait ( ) ;
87
92
return ;
88
93
}
89
94
90
- if ( canLiveSyncAction && ! canLiveSyncAction ( device , appIdentifier ) . wait ( ) ) {
91
- return ;
92
- }
93
-
94
95
this . $logger . info ( "Transfering project files..." ) ;
95
96
device . fileSystem . transferFiles ( deviceAppData . appIdentifier , localToDevicePaths ) . wait ( ) ;
96
97
this . $logger . info ( "Successfully transfered all project files." ) ;
@@ -108,11 +109,11 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
108
109
109
110
private timer : any = null ;
110
111
private syncQueue : string [ ] = [ ] ;
111
- private batchLiveSync ( filePath : string , appIdentifier : string , localProjectRootPath : string ,
112
+ private batchLiveSync ( filePath : string , appIdentifier : string , projectFilesPath : string ,
112
113
restartAppOnDeviceAction : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) => IFuture < void > ,
113
114
notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ,
114
- beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ,
115
- canLiveSyncAction ?: ( device : Mobile . IDevice , appIdentifier : string ) => IFuture < boolean > ) : void {
115
+ beforeLiveSyncAction ?: ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) => IFuture < void > ,
116
+ beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ) : void {
116
117
if ( ! this . timer ) {
117
118
this . timer = setInterval ( ( ) => {
118
119
let filesToSync = this . syncQueue ;
@@ -121,7 +122,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
121
122
this . $logger . trace ( "Syncing %s" , filesToSync . join ( ", " ) ) ;
122
123
this . $dispatcher . dispatch ( ( ) => {
123
124
return ( ( ) => {
124
- this . syncCore ( filesToSync , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , canLiveSyncAction ) . wait ( ) ;
125
+ this . syncCore ( filesToSync , appIdentifier , projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeLiveSyncAction ) . wait ( ) ;
125
126
} ) . future < void > ( ) ( ) ;
126
127
} ) ;
127
128
}
0 commit comments