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

Commit cac6a77

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
PR comments
1 parent b4b1c0d commit cac6a77

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

mobile/ios/ios-emulator-services.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import Future = require("fibers/future");
55
import * as path from "path";
66
import * as shell from "shelljs";
77

8+
interface IiOSSim {
9+
getRunningSimulator(appIdentifier: string): { id: string };
10+
getApplicationPath(runningSimulatorId: string, appIdentifier: string): string;
11+
}
12+
813
class IosEmulatorServices implements Mobile.IiOSSimulatorService {
914
constructor(private $logger: ILogger,
1015
private $emulatorSettingsService: Mobile.IEmulatorSettingsService,
@@ -89,6 +94,15 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService {
8994
}).future<boolean>()();
9095
}
9196

97+
private _iosSim: IiOSSim = null;
98+
private get iosSim(): IiOSSim {
99+
if (!this._iosSim) {
100+
this._iosSim = require("ios-sim-portable");
101+
}
102+
103+
return this._iosSim;
104+
}
105+
92106
private startEmulatorCore(app: string, emulatorOptions?: Mobile.IEmulatorOptions): any {
93107
this.$logger.info("Starting iOS Simulator");
94108
let iosSimPath = require.resolve("ios-sim-portable");
@@ -174,18 +188,14 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService {
174188
}
175189

176190
private getApplicationPath(appIdentifier: string): string {
177-
let iosSim = require("ios-sim-portable");
178191
let runningSimulatorId = this.getRunningSimulatorId(appIdentifier);
179-
let applicationPath = iosSim.getApplicationPath(runningSimulatorId, appIdentifier);
192+
let applicationPath = this.iosSim.getApplicationPath(runningSimulatorId, appIdentifier);
180193
return applicationPath;
181194
}
182195

183196
private getRunningSimulatorId(appIdentifier: string): string {
184-
let iosSim = require("ios-sim-portable");
185-
186-
let runningSimulator = iosSim.getRunningSimulator(appIdentifier);
197+
let runningSimulator = this.iosSim.getRunningSimulator(appIdentifier);
187198
let runningSimulatorId = runningSimulator.id;
188-
189199
return runningSimulatorId;
190200
}
191201
}

services/usb-livesync-service-base.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
8686
this.$iOSEmulatorServices.sync(data.appIdentifier, data.projectFilesPath, data.notRunningiOSSimulatorAction).wait();
8787
}
8888

89-
if(!this._initialized && (!this.$options.emulator || data.platform.toLowerCase() === "android")) {
90-
this.initialize(data.platform).wait();
91-
}
89+
if (!this.$options.emulator || data.platform.toLowerCase() === "android") {
90+
if (!this._initialized) {
91+
this.initialize(data.platform).wait();
92+
}
9293

93-
if(!this.$options.emulator || data.platform.toLowerCase() === "android") {
9494
let projectFiles = this.$fs.enumerateFilesInDirectorySync(data.projectFilesPath,
9595
(filePath, stat) => !this.isFileExcluded(path.relative(data.projectFilesPath, filePath), data.excludedProjectDirsAndFiles, data.projectFilesPath),
9696
{ enumerateDirectories: true }
@@ -106,15 +106,15 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
106106

107107
gaze("**/*", { cwd: data.watchGlob }, function(err: any, watcher: any) {
108108
this.on('all', (event: string, filePath: string) => {
109-
if(event === "added" || event === "changed") {
110-
if(!that.isFileExcluded(filePath, data.excludedProjectDirsAndFiles, data.projectFilesPath)) {
109+
if (event === "added" || event === "changed") {
110+
if (!that.isFileExcluded(filePath, data.excludedProjectDirsAndFiles, data.projectFilesPath)) {
111111
let canExecuteFastLiveSync = data.canExecuteFastLiveSync && data.canExecuteFastLiveSync(filePath);
112112

113-
if(synciOSSimulator && !canExecuteFastLiveSync) {
113+
if (synciOSSimulator && !canExecuteFastLiveSync) {
114114
that.batchSimulatorLiveSync(data, filePath);
115115
}
116116

117-
if( (!that.$options.emulator || data.platform.toLowerCase() === "android") && !canExecuteFastLiveSync) {
117+
if ((!that.$options.emulator || data.platform.toLowerCase() === "android") && !canExecuteFastLiveSync) {
118118
that.batchLiveSync(data, filePath);
119119
}
120120

0 commit comments

Comments
 (0)