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

Commit e1b792c

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
PR comments and some improvements
1 parent f411899 commit e1b792c

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

mobile/ios/ios-core.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,25 +1199,13 @@ export class GDBServer implements Mobile.IGDBServer {
11991199
let retryCount = 3;
12001200
let isDataReceived = false;
12011201

1202-
let dataCallback = (data: any) => {
1203-
let dataAsString = data.toString();
1204-
if (dataAsString.indexOf("thread") > -1) {
1205-
isDataReceived = true;
1206-
this.socket.removeListener("data", dataCallback);
1207-
future.return(data.toString());
1208-
}
1209-
};
1210-
1211-
this.socket.on("data", dataCallback);
1212-
this.sendCore("\x03");
1213-
12141202
let timer = setInterval(() => {
12151203
this.sendCore("\x03");
12161204
retryCount--;
12171205

1218-
let secondTimer = setInterval(() => {
1206+
let secondTimer = setTimeout(() => {
12191207
if (isDataReceived || !retryCount) {
1220-
clearInterval(secondTimer);
1208+
clearTimeout(secondTimer);
12211209
clearInterval(timer);
12221210
}
12231211

@@ -1227,6 +1215,19 @@ export class GDBServer implements Mobile.IGDBServer {
12271215
}, 1000);
12281216
}, 1000);
12291217

1218+
let dataCallback = (data: any) => {
1219+
let dataAsString = data.toString();
1220+
if (dataAsString.indexOf("thread") > -1) {
1221+
isDataReceived = true;
1222+
this.socket.removeListener("data", dataCallback);
1223+
clearInterval(timer);
1224+
future.return(data.toString());
1225+
}
1226+
};
1227+
1228+
this.socket.on("data", dataCallback);
1229+
this.sendCore("\x03");
1230+
12301231
return future;
12311232
}
12321233

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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SyncBatch {
3939
});
4040
}
4141
this.timer = null;
42-
}, 250);
42+
}, 250); // https://github.com/Microsoft/TypeScript/blob/master/src/compiler/tsc.ts#L487-L489
4343
}
4444

4545
public get syncPending() {
@@ -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)