Skip to content

Commit 4528b59

Browse files
Merge pull request #87 from telerik/yosifov/start-to-respect-deviceid
Modify startSimulator to kill the booted one if it's not with the sam…
2 parents 05ea7bf + 631032d commit 4528b59

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/iphone-simulator-xcode-simctl.ts

100644100755
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,20 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
148148
public startSimulator(device?: IDevice): void {
149149
device = device || this.getDeviceToRun();
150150
if (!this.isDeviceBooted(device)) {
151+
let bootedDevice = this.getBootedDevice();
152+
if(bootedDevice && bootedDevice.id !== device.id) {
153+
this.killSimulator();
154+
}
155+
151156
common.startSimulator(device.id);
152157
// startSimulaltor doesn't always finish immediately, and the subsequent
153158
// install fails since the simulator is not running.
154159
// Give it some time to start before we attempt installing.
155-
utils.sleep(1000);
160+
utils.sleep(1000);
156161
}
157162
}
158-
163+
159164
private killSimulator(): Promise<any> {
160-
return childProcess.spawn("pkill", ["-9", "-f", "Simulator"]);
165+
childProcess.execSync("pkill -9 -f Simulator");
161166
}
162-
}
167+
}

0 commit comments

Comments
 (0)