@@ -37,28 +37,28 @@ 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 < void > ) : IFuture < void > {
40
+ beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ) : IFuture < void > {
41
41
return ( ( ) => {
42
42
if ( ! this . _initialized ) {
43
43
this . initialize ( platform ) . wait ( ) ;
44
44
}
45
45
46
+ 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
+
46
49
if ( this . $options . watch ) {
47
50
let __this = this ;
48
51
49
52
gaze ( watchGlob , function ( err : any , watcher : any ) {
50
- this . on ( 'changed' , ( filePath : string ) => {
53
+ this . on ( 'changed' , ( filePath : string ) => {
51
54
if ( ! _ . contains ( excludedProjectDirsAndFiles , filePath ) ) {
52
55
__this . batchLiveSync ( filePath , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeBatchLiveSyncAction ) ;
53
56
}
54
57
} ) ;
55
58
} ) ;
56
59
57
60
this . $dispatcher . run ( ) ;
58
- } else {
59
- let projectFiles = this . $fs . enumerateFilesInDirectorySync ( projectFilesPath , ( filePath , stat ) => ! this . isFileExcluded ( path . relative ( projectFilesPath , filePath ) , excludedProjectDirsAndFiles , projectFilesPath ) , { enumerateDirectories : true } ) ;
60
- this . syncCore ( projectFiles , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction ) . wait ( ) ;
61
- }
61
+ }
62
62
} ) . future < void > ( ) ( ) ;
63
63
}
64
64
@@ -103,7 +103,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
103
103
private batchLiveSync ( filePath : string , appIdentifier : string , localProjectRootPath : string ,
104
104
restartAppOnDeviceAction : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) => IFuture < void > ,
105
105
notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ,
106
- beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < void > ) : void {
106
+ beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ) : void {
107
107
if ( ! this . timer ) {
108
108
this . timer = setInterval ( ( ) => {
109
109
let filesToSync = this . syncQueue ;
@@ -112,16 +112,13 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
112
112
this . $logger . trace ( "Syncing %s" , filesToSync . join ( ", " ) ) ;
113
113
this . $dispatcher . dispatch ( ( ) => {
114
114
return ( ( ) => {
115
- if ( beforeBatchLiveSyncAction ) {
116
- beforeBatchLiveSyncAction ( filePath ) . wait ( ) ;
117
- }
118
- this . syncCore ( [ filePath ] , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction ) . wait ( ) ;
115
+ this . syncCore ( filesToSync , appIdentifier , localProjectRootPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction ) . wait ( ) ;
119
116
} ) . future < void > ( ) ( ) ;
120
117
} ) ;
121
118
}
122
119
} , 500 ) ;
123
120
}
124
- this . syncQueue . push ( filePath ) ;
121
+ this . $dispatcher . dispatch ( ( ) => ( ( ) => { this . syncQueue . push ( beforeBatchLiveSyncAction ( filePath ) . wait ( ) ) } ) . future < void > ( ) ( ) ) ;
125
122
}
126
123
127
124
private isFileExcluded ( path : string , exclusionList : string [ ] , projectDir : string ) : boolean {
0 commit comments