Skip to content

Commit c426512

Browse files
Merge pull request #1870 from NativeScript/KristinaKoeva/Refactoring
Execute batch sync when you live sync application with the --watch option
2 parents 13faa66 + 21bd6db commit c426512

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

lib/services/livesync/android-livesync-service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ class AndroidLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase<
1414
private $mobileHelper: Mobile.IMobileHelper,
1515
private $options: IOptions,
1616
private $injector: IInjector,
17-
private $projectData: IProjectData) {
18-
super(_device);
17+
private $projectData: IProjectData,
18+
$liveSyncProvider: ILiveSyncProvider) {
19+
super(_device, $liveSyncProvider);
1920
}
2021

2122
public restartApplication(deviceAppData: Mobile.IDeviceAppData): IFuture<void> {

lib/services/livesync/ios-livesync-service.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ class IOSLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase<Mobi
1414
private $iOSEmulatorServices: Mobile.IiOSSimulatorService,
1515
private $injector: IInjector,
1616
private $logger: ILogger,
17-
private $options: IOptions) {
18-
super(_device);
19-
}
17+
private $options: IOptions,
18+
$liveSyncProvider: ILiveSyncProvider) {
19+
super(_device, $liveSyncProvider);
20+
}
2021

2122
public removeFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> {
2223
return (() => {

lib/services/livesync/livesync-service-base.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ export abstract class LiveSyncServiceBase<T extends Mobile.IDevice> {
33
return <T>(this._device);
44
}
55

6-
constructor(private _device: Mobile.IDevice) { }
6+
constructor(private _device: Mobile.IDevice,
7+
private $liveSyncProvider: ILiveSyncProvider) { }
78

8-
public refreshApplication(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], canExecuteFastSync?: boolean): IFuture<void> {
9+
public refreshApplication(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], forceExecuteFullSync: boolean): IFuture<void> {
10+
let canExecuteFastSync = !forceExecuteFullSync && localToDevicePaths &&
11+
_.all(localToDevicePaths, localToDevicePath => this.$liveSyncProvider.canExecuteFastSync(localToDevicePath.getLocalPath(), deviceAppData.platform));
912
if (canExecuteFastSync) {
1013
return this.reloadPage(deviceAppData);
1114
}

lib/services/test-execution-service.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,7 @@ class TestExecutionService implements ITestExecutionService {
6464
}
6565
this.detourEntryPoint(projectFilesPath).wait();
6666

67-
let liveSyncData = {
68-
platform: platform,
69-
appIdentifier: this.$projectData.projectId,
70-
projectFilesPath: projectFilesPath,
71-
syncWorkingDirectory: path.join(projectDir, constants.APP_FOLDER_NAME)
72-
};
73-
74-
this.$liveSyncServiceBase.sync(liveSyncData).wait();
67+
this.liveSyncProject(platform);
7568

7669
if (this.$options.debugBrk) {
7770
this.$logger.info('Starting debugger...');
@@ -233,8 +226,8 @@ class TestExecutionService implements ITestExecutionService {
233226
platform: platform,
234227
appIdentifier: this.$projectData.projectId,
235228
projectFilesPath: projectFilesPath,
229+
forceExecuteFullSync: true, // Always restart the application when change is detected, so tests will be rerun.
236230
syncWorkingDirectory: path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME),
237-
canExecuteFastSync: false, // Always restart the application when change is detected, so tests will be rerun.
238231
excludedProjectDirsAndFiles: this.$options.release ? constants.LIVESYNC_EXCLUDED_FILE_PATTERNS : []
239232
};
240233

0 commit comments

Comments
 (0)