Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,31 +436,44 @@ export class PlatformService implements IPlatformService {
let platformData = this.$platformsData.getPlatformData(platform);

this.$devicesService.initialize({ platform: platform, deviceId: this.$options.device }).wait();
let packageFile: string = null;
let packageFileDict: IStringDictionary = {};

let action = (device: Mobile.IDevice): IFuture<void> => {
return (() => {

let packageFileKey = this.getPackageFileKey(device);
let packageFile = packageFileDict[packageFileKey];
if (!packageFile) {
if (this.$devicesService.isiOSSimulator(device)) {
this.prepareAndExecute(platform, () => this.buildForDeploy(platform, buildConfig)).wait();
packageFile = this.getLatestApplicationPackageForEmulator(platformData).wait().packageName;
} else {
buildConfig = buildConfig || {};
buildConfig.buildForDevice = true;
this.prepareAndExecute(platform, () => this.buildForDeploy(platform, buildConfig)).wait();
let deviceBuildConfig = buildConfig || {};
deviceBuildConfig.buildForDevice = true;
this.prepareAndExecute(platform, () => this.buildForDeploy(platform, deviceBuildConfig)).wait();
packageFile = this.getLatestApplicationPackageForDevice(platformData).wait().packageName;
}
}

platformData.platformProjectService.deploy(device.deviceInfo.identifier).wait();
device.applicationManager.reinstallApplication(this.$projectData.projectId, packageFile).wait();
this.$logger.info(`Successfully deployed on device with identifier '${device.deviceInfo.identifier}'.`);

packageFileDict[packageFileKey] = packageFile;

}).future<void>()();
};
this.$devicesService.execute(action, this.getCanExecuteAction(platform)).wait();
}).future<void>()();
}

private getPackageFileKey(device: Mobile.IDevice): string {
if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
return device.deviceInfo.platform.toLowerCase();
}
return device.deviceInfo.platform.toLowerCase() + device.deviceInfo.type;
}

public deployOnDevice(platform: string, buildConfig?: IBuildConfig): IFuture<void> {
return (() => {
this.installOnDevice(platform, buildConfig).wait();
Expand Down