@@ -26,15 +26,16 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
26
26
private $fs : IFileSystem ,
27
27
private $dispatcher : IFutureDispatcher ,
28
28
protected $childProcess : IChildProcess ,
29
- protected $iOSEmulatorServices : Mobile . IiOSSimulatorService ) { }
29
+ protected $iOSEmulatorServices : Mobile . IiOSSimulatorService ,
30
+ private $hostInfo : IHostInfo ) { }
30
31
31
32
public initialize ( platform : string ) : IFuture < string > {
32
33
return ( ( ) => {
33
- if ( ! this . $options . emulator ) {
34
+ if ( ! ( this . $options . emulator && platform && platform . toLowerCase ( ) === "ios" ) ) {
34
35
this . $devicesServices . initialize ( { platform : platform , deviceId : this . $options . device } ) . wait ( ) ;
35
36
this . _initialized = true ;
36
37
return this . $devicesServices . platform ;
37
- }
38
+ }
38
39
} ) . future < string > ( ) ( ) ;
39
40
}
40
41
@@ -46,18 +47,19 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
46
47
beforeLiveSyncAction ?: ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) => IFuture < void > ,
47
48
beforeBatchLiveSyncAction ?: ( filePath : string ) => IFuture < string > ) : IFuture < void > {
48
49
return ( ( ) => {
49
- if ( ! this . _initialized && ! this . $options . emulator ) {
50
- this . initialize ( platform ) . wait ( ) ;
51
- }
50
+ let synciOSSimulator = this . $hostInfo . isDarwin ? this . $iOSEmulatorServices . isSimulatorRunning ( ) . wait ( ) || ( this . $options . emulator && platform . toLowerCase ( ) === "ios" ) : false ;
52
51
53
- let isiOSSimulatorRunning = this . $iOSEmulatorServices . isSimulatorRunning ( ) . wait ( ) ;
54
- if ( isiOSSimulatorRunning || this . $options . emulator ) {
52
+ if ( synciOSSimulator ) {
55
53
this . $iOSEmulatorServices . sync ( appIdentifier , projectFilesPath , notRunningiOSSimulatorAction ) . wait ( ) ;
56
54
}
57
55
58
- if ( ! this . $options . emulator ) {
56
+ if ( ! this . _initialized && ( ! this . $options . emulator || platform . toLowerCase ( ) === "android" ) ) {
57
+ this . initialize ( platform ) . wait ( ) ;
58
+ }
59
+
60
+ if ( ! this . $options . emulator || platform . toLowerCase ( ) === "android" ) {
59
61
let projectFiles = this . $fs . enumerateFilesInDirectorySync ( projectFilesPath , ( filePath , stat ) => ! this . isFileExcluded ( path . relative ( projectFilesPath , filePath ) , excludedProjectDirsAndFiles , projectFilesPath ) , { enumerateDirectories : true } ) ;
60
- this . syncCore ( projectFiles , appIdentifier , localProjectRootPath || projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction ) . wait ( ) ;
62
+ this . syncCore ( platform , projectFiles , appIdentifier , localProjectRootPath || projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction ) . wait ( ) ;
61
63
}
62
64
63
65
if ( this . $options . watch ) {
@@ -67,12 +69,12 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
67
69
this . on ( 'all' , ( event : string , filePath : string ) => {
68
70
if ( event === "added" || event === "changed" ) {
69
71
if ( ! _ . contains ( excludedProjectDirsAndFiles , filePath ) ) {
70
- if ( isiOSSimulatorRunning || __this . $options . emulator ) {
72
+ if ( synciOSSimulator ) {
71
73
__this . $dispatcher . dispatch ( ( ) => __this . $iOSEmulatorServices . syncFiles ( appIdentifier , projectFilesPath , [ filePath ] , notRunningiOSSimulatorAction ) ) ;
72
74
}
73
75
74
- if ( ! __this . $options . emulator ) {
75
- __this . batchLiveSync ( filePath , appIdentifier , projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeLiveSyncAction , beforeBatchLiveSyncAction ) ;
76
+ if ( ! __this . $options . emulator || platform . toLowerCase ( ) === "android" ) {
77
+ __this . batchLiveSync ( platform , filePath , appIdentifier , projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeLiveSyncAction , beforeBatchLiveSyncAction ) ;
76
78
}
77
79
}
78
80
}
@@ -84,12 +86,13 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
84
86
} ) . future < void > ( ) ( ) ;
85
87
}
86
88
87
- private syncCore ( projectFiles : string [ ] , appIdentifier : string , projectFilesPath : string ,
89
+ private syncCore ( platform : string , projectFiles : string [ ] , appIdentifier : string , projectFilesPath : string ,
88
90
restartAppOnDeviceAction : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) => IFuture < void > ,
89
91
notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ,
90
92
beforeLiveSyncAction ?: ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) => IFuture < void > ) : IFuture < void > {
91
93
return ( ( ) => {
92
- let deviceAppData = this . $deviceAppDataFactory . create ( appIdentifier , this . $devicesServices . platform ) ;
94
+ platform = platform ? this . $mobileHelper . normalizePlatformName ( platform ) : this . $devicesServices . platform ;
95
+ let deviceAppData = this . $deviceAppDataFactory . create ( appIdentifier , platform ) ;
93
96
let localToDevicePaths = _ ( projectFiles )
94
97
. map ( projectFile => this . getProjectFileInfo ( projectFile ) )
95
98
. filter ( projectFileInfo => projectFileInfo . shouldIncludeFile )
@@ -128,7 +131,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
128
131
129
132
private timer : any = null ;
130
133
private syncQueue : string [ ] = [ ] ;
131
- private batchLiveSync ( filePath : string , appIdentifier : string , projectFilesPath : string ,
134
+ private batchLiveSync ( platform : string , filePath : string , appIdentifier : string , projectFilesPath : string ,
132
135
restartAppOnDeviceAction : ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) => IFuture < void > ,
133
136
notInstalledAppOnDeviceAction : ( device : Mobile . IDevice ) => IFuture < void > ,
134
137
beforeLiveSyncAction ?: ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) => IFuture < void > ,
@@ -141,7 +144,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
141
144
this . $logger . trace ( "Syncing %s" , filesToSync . join ( ", " ) ) ;
142
145
this . $dispatcher . dispatch ( ( ) => {
143
146
return ( ( ) => {
144
- this . syncCore ( filesToSync , appIdentifier , projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeLiveSyncAction ) . wait ( ) ;
147
+ this . syncCore ( platform , filesToSync , appIdentifier , projectFilesPath , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeLiveSyncAction ) . wait ( ) ;
145
148
} ) . future < void > ( ) ( ) ;
146
149
} ) ;
147
150
}
0 commit comments