Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 689f53d

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #382 from telerik/fatme/fix-livesync-watch
Fix live sync --watch
2 parents 138a263 + abd9db0 commit 689f53d

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

declarations.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ interface IUsbLiveSyncServiceBase {
266266
sync(platform: string, appIdentifier: string, localProjectRootPath: string, projectFilesPath: string, excludedProjectDirsAndFiles: string[], watchGlob: any,
267267
restartAppOnDeviceAction: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData) => IFuture<void>,
268268
notInstalledAppOnDeviceAction: (device: Mobile.IDevice) => IFuture<void>,
269-
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<void>): IFuture<void>;
269+
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>): IFuture<void>;
270270
}
271271

272272
interface ISysInfoData {

mobile/android/android-application-manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class AndroidApplicationManager implements Mobile.IDeviceApplicationManag
3131
}
3232

3333
public uninstallApplication(appIdentifier: string): IFuture<void> {
34-
return Future.fromResult();
34+
return this.adb.executeShellCommand(`pm uninstall "${appIdentifier}"`);
3535
}
3636

3737
public startApplication(appIdentifier: string): IFuture<void> {

services/usb-livesync-service-base.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
3737
public sync(platform: string, appIdentifier: string, localProjectRootPath: string, projectFilesPath: string, excludedProjectDirsAndFiles: string[], watchGlob: any,
3838
restartAppOnDeviceAction: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths?: Mobile.ILocalToDevicePathData[]) => IFuture<void>,
3939
notInstalledAppOnDeviceAction: (device: Mobile.IDevice) => IFuture<void>,
40-
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<void>): IFuture<void> {
40+
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>): IFuture<void> {
4141
return (() => {
4242
if(!this._initialized) {
4343
this.initialize(platform).wait();
4444
}
4545

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+
4649
if(this.$options.watch) {
4750
let __this = this;
4851

4952
gaze(watchGlob, function(err: any, watcher: any) {
50-
this.on('changed',(filePath: string) => {
53+
this.on('changed', (filePath: string) => {
5154
if(!_.contains(excludedProjectDirsAndFiles, filePath)) {
5255
__this.batchLiveSync(filePath, appIdentifier, localProjectRootPath, restartAppOnDeviceAction, notInstalledAppOnDeviceAction, beforeBatchLiveSyncAction);
5356
}
5457
});
5558
});
5659

5760
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+
}
6262
}).future<void>()();
6363
}
6464

@@ -103,7 +103,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
103103
private batchLiveSync(filePath: string, appIdentifier: string, localProjectRootPath: string,
104104
restartAppOnDeviceAction: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths?: Mobile.ILocalToDevicePathData[]) => IFuture<void>,
105105
notInstalledAppOnDeviceAction: (device: Mobile.IDevice) => IFuture<void>,
106-
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<void>) : void {
106+
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>) : void {
107107
if(!this.timer) {
108108
this.timer = setInterval(() => {
109109
let filesToSync = this.syncQueue;
@@ -112,16 +112,13 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
112112
this.$logger.trace("Syncing %s", filesToSync.join(", "));
113113
this.$dispatcher.dispatch( () => {
114114
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();
119116
}).future<void>()();
120117
});
121118
}
122119
}, 500);
123120
}
124-
this.syncQueue.push(filePath);
121+
this.$dispatcher.dispatch( () => (() => { this.syncQueue.push(beforeBatchLiveSyncAction(filePath).wait()) }).future<void>()());
125122
}
126123

127124
private isFileExcluded(path: string, exclusionList: string[], projectDir: string): boolean {

0 commit comments

Comments
 (0)