Skip to content

Commit

Permalink
Support for xcode7 simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatme Havaluova authored and Fatme Havaluova committed Oct 21, 2015
1 parent d715cae commit 0131f6f
Show file tree
Hide file tree
Showing 11 changed files with 759 additions and 350 deletions.
54 changes: 54 additions & 0 deletions lib/child-process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
///<reference path="./.d.ts"/>
"use strict";

import child_process = require("child_process");
import errors = require("./errors");
import Future = require("fibers/future");
import util = require("util");

export function exec(command: string): IFuture<any> {
var future = new Future<any>();

child_process.exec(command, (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) => {
//console.log(util.format("Executing: %s", command));

if(error) {
errors.fail(util.format("Error %s while executing %s.", error.message, command));
} else {
future.return(stdout ? stdout.toString() : "");
}
});

return future;
}

export function spawn(command: string, args: string[]): IFuture<string> {
let future = new Future<string>();
let capturedOut = "";
let capturedErr = "";

let childProcess = child_process.spawn(command, args);

if(childProcess.stdout) {
childProcess.stdout.on("data", (data: string) => {
capturedOut += data;
});
}

if(childProcess.stderr) {
childProcess.stderr.on("data", (data: string) => {
capturedErr += data;
});
}

childProcess.on("close", (arg: any) => {
var exitCode = typeof arg == 'number' ? arg : arg && arg.code;
if(exitCode === 0) {
future.return(capturedOut ? capturedOut.trim() : null);
} else {
future.throw(util.format("Command %s with arguments %s failed with exit code %s. Error output: \n %s", command, args.join(" "), exitCode, capturedErr));
}
});

return future;
}
2 changes: 1 addition & 1 deletion lib/commands/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import iphoneSimulatorLibPath = require("./../iphone-simulator");
export class Command implements ICommand {
public execute(args: string[]): IFuture<void> {
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
return iphoneSimulator.run(args[0]);
return iphoneSimulator.run(args[0], args[1]);
}
}
37 changes: 29 additions & 8 deletions lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use strict";

interface IiPhoneSimulator {
run(appName: string): IFuture<void>;
run(applicationPath: string, applicationIdentifier: string): IFuture<void>;
printDeviceTypes(): IFuture<void>;
printSDKS(): IFuture<void>;
sendNotification(notification: string): IFuture<void>;
Expand All @@ -17,22 +17,38 @@ interface ICommandExecutor {
}

interface IDevice {
device: any; // NodObjC wrapper to device
deviceIdentifier: string;
fullDeviceIdentifier: string;
name: string;
id: string;
fullId: string;
runtimeVersion: string;
state?: string;
rawDevice?: any; // NodObjC wrapper to device
}

interface ISimctl {
launch(deviceId: string, applicationIdentifier: string): IFuture<void>;
install(deviceId: string, applicationPath: string): IFuture<void>;
uninstall(deviceId: string, applicationIdentifier: string): IFuture<void>;
notifyPost(deviceId: string, notification: string): IFuture<void>;
getDevices(): IFuture<IDevice[]>;
}

interface IDictionary<T> {
[key: string]: T;
}

interface ISimulator {
validDeviceIdentifiers: string[];
deviceIdentifiersInfo: string[];
interface IInteropSimulator {
getDevices(): IFuture<IDevice[]>;
setSimulatedDevice(config: any): void;
}

interface ISimulator {
getDevices(): IFuture<IDevice[]>;
getSdks(): IFuture<ISdk[]>;
run(applicationPath: string, applicationIdentifier: string): IFuture<void>;
sendNotification(notification: string): IFuture<void>;
}

interface IExecuteOptions {
canRunMainLoop: boolean;
appPath?: string;
Expand All @@ -42,5 +58,10 @@ interface ISdk {
displayName: string;
version: string;
rootPath: string;
sdkInfo(): string;
}

interface IXcodeVersionData {
major: string;
minor: string;
build: string;
}
Loading

0 comments on commit 0131f6f

Please sign in to comment.