@@ -4,8 +4,6 @@ import { cache, performanceLog } from "../common/decorators";
44import { EventEmitter } from "events" ;
55
66export class RunController extends EventEmitter implements IRunController {
7- private rebuiltInformation : IDictionary < { packageFilePath : string , platform : string , isEmulator : boolean } > = { } ;
8-
97 constructor (
108 protected $analyticsService : IAnalyticsService ,
119 private $buildController : IBuildController ,
@@ -246,7 +244,7 @@ export class RunController extends EventEmitter implements IRunController {
246244 }
247245
248246 private async syncInitialDataOnDevices ( projectData : IProjectData , liveSyncInfo : ILiveSyncInfo , deviceDescriptors : ILiveSyncDeviceDescriptor [ ] ) : Promise < void > {
249- this . rebuiltInformation = { } ;
247+ const rebuiltInformation : IDictionary < { packageFilePath : string , platform : string , isEmulator : boolean } > = { } ;
250248
251249 const deviceAction = async ( device : Mobile . IDevice ) => {
252250 const deviceDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
@@ -267,14 +265,14 @@ export class RunController extends EventEmitter implements IRunController {
267265
268266 // Case where we have three devices attached, a change that requires build is found,
269267 // we'll rebuild the app only for the first device, but we should install new package on all three devices.
270- if ( this . rebuiltInformation [ platformData . platformNameLowerCase ] && ( this . $mobileHelper . isAndroidPlatform ( platformData . platformNameLowerCase ) || this . rebuiltInformation [ platformData . platformNameLowerCase ] . isEmulator === device . isEmulator ) ) {
271- packageFilePath = this . rebuiltInformation [ platformData . platformNameLowerCase ] . packageFilePath ;
268+ if ( rebuiltInformation [ platformData . platformNameLowerCase ] && ( this . $mobileHelper . isAndroidPlatform ( platformData . platformNameLowerCase ) || rebuiltInformation [ platformData . platformNameLowerCase ] . isEmulator === device . isEmulator ) ) {
269+ packageFilePath = rebuiltInformation [ platformData . platformNameLowerCase ] . packageFilePath ;
272270 await this . $deviceInstallAppService . installOnDevice ( device , buildData , packageFilePath ) ;
273271 } else {
274272 const shouldBuild = prepareResultData . hasNativeChanges || await this . $buildController . shouldBuild ( buildData ) ;
275273 if ( shouldBuild ) {
276274 packageFilePath = await deviceDescriptor . buildAction ( ) ;
277- this . rebuiltInformation [ platformData . platformNameLowerCase ] = { isEmulator : device . isEmulator , platform : platformData . platformNameLowerCase , packageFilePath } ;
275+ rebuiltInformation [ platformData . platformNameLowerCase ] = { isEmulator : device . isEmulator , platform : platformData . platformNameLowerCase , packageFilePath } ;
278276 } else {
279277 await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
280278 action : TrackActionNames . LiveSync ,
@@ -315,7 +313,7 @@ export class RunController extends EventEmitter implements IRunController {
315313 }
316314
317315 private async syncChangedDataOnDevices ( data : IFilesChangeEventData , projectData : IProjectData , liveSyncInfo : ILiveSyncInfo , deviceDescriptors : ILiveSyncDeviceDescriptor [ ] ) : Promise < void > {
318- this . rebuiltInformation = { } ;
316+ const rebuiltInformation : IDictionary < { packageFilePath : string , platform : string , isEmulator : boolean } > = { } ;
319317
320318 const deviceAction = async ( device : Mobile . IDevice ) => {
321319 const deviceDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
@@ -343,14 +341,14 @@ export class RunController extends EventEmitter implements IRunController {
343341 const deviceAppData = await platformLiveSyncService . getAppData ( _ . merge ( { device, watch : true } , watchInfo ) ) ;
344342
345343 if ( data . hasNativeChanges ) {
346- const rebuiltInfo = this . rebuiltInformation [ platformData . platformNameLowerCase ] && ( this . $mobileHelper . isAndroidPlatform ( platformData . platformNameLowerCase ) || this . rebuiltInformation [ platformData . platformNameLowerCase ] . isEmulator === device . isEmulator ) ;
344+ const rebuiltInfo = rebuiltInformation [ platformData . platformNameLowerCase ] && ( this . $mobileHelper . isAndroidPlatform ( platformData . platformNameLowerCase ) || rebuiltInformation [ platformData . platformNameLowerCase ] . isEmulator === device . isEmulator ) ;
347345 if ( ! rebuiltInfo ) {
348346 await this . $prepareNativePlatformService . prepareNativePlatform ( platformData , projectData , prepareData ) ;
349347 await deviceDescriptor . buildAction ( ) ;
350- this . rebuiltInformation [ platformData . platformNameLowerCase ] = { isEmulator : device . isEmulator , platform : platformData . platformNameLowerCase , packageFilePath : null } ;
348+ rebuiltInformation [ platformData . platformNameLowerCase ] = { isEmulator : device . isEmulator , platform : platformData . platformNameLowerCase , packageFilePath : null } ;
351349 }
352350
353- await this . $deviceInstallAppService . installOnDevice ( device , deviceDescriptor . buildData , this . rebuiltInformation [ platformData . platformNameLowerCase ] . packageFilePath ) ;
351+ await this . $deviceInstallAppService . installOnDevice ( device , deviceDescriptor . buildData , rebuiltInformation [ platformData . platformNameLowerCase ] . packageFilePath ) ;
354352 await platformLiveSyncService . syncAfterInstall ( device , watchInfo ) ;
355353 await platformLiveSyncService . restartApplication ( projectData , { deviceAppData, modifiedFilesData : [ ] , isFullSync : false , useHotModuleReload : liveSyncInfo . useHotModuleReload } ) ;
356354 } else {
0 commit comments