Skip to content

Commit c63f9ce

Browse files
committed
chore: refactor package to latest deps
1 parent cded444 commit c63f9ce

21 files changed

+871
-796
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22

33
*.js
4+
*.d.ts
45
!/*.js
56
!bin/ios-sim-portable.js
67
*.js.map

Gruntfile.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

lib/command-executor.ts

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
import fs = require("fs");
2-
import path = require("path");
3-
import errors = require("./errors");
4-
import options = require("./options");
1+
import * as fs from "fs";
2+
import * as path from "path";
3+
import * as errors from "./errors";
4+
import * as options from "./options";
55

66
export class CommandExecutor implements ICommandExecutor {
7-
8-
public execute(): void {
9-
var commandName = this.getCommandName();
10-
var commandArguments = this.getCommandArguments();
11-
12-
return this.executeCore(commandName, commandArguments);
13-
}
14-
15-
private executeCore(commandName: string, commandArguments: string[]): void {
16-
try {
17-
let filePath = path.join(__dirname, "commands", commandName + ".js");
18-
if (fs.existsSync(filePath)) {
19-
var command: ICommand = new (require(filePath).Command)();
20-
if (!command) {
21-
errors.fail("Unable to resolve commandName %s", commandName);
22-
}
23-
24-
command.execute(commandArguments);
25-
}
26-
27-
} catch (e) {
28-
if (options.debug) {
29-
throw e;
30-
} else {
31-
console.log("\x1B[31;1m" + e.message + "\x1B[0m");
32-
}
33-
}
34-
}
35-
36-
private getCommandArguments(): string[] {
37-
var remaining = options._;
38-
return remaining.length > 1 ? remaining.slice(1) : [];
39-
}
40-
41-
private getCommandName(): string {
42-
var remaining = options._;
43-
return remaining.length > 0 ? remaining[0].toLowerCase() : "help";
44-
}
45-
}
7+
public execute(): void {
8+
var commandName = this.getCommandName();
9+
var commandArguments = this.getCommandArguments();
10+
11+
return this.executeCore(commandName, commandArguments);
12+
}
13+
14+
private executeCore(commandName: string, commandArguments: string[]): void {
15+
try {
16+
let filePath = path.join(__dirname, "commands", commandName + ".js");
17+
if (fs.existsSync(filePath)) {
18+
var command: ICommand = new (require(filePath).Command)();
19+
if (!command) {
20+
errors.fail("Unable to resolve commandName %s", commandName);
21+
}
22+
23+
command.execute(commandArguments);
24+
}
25+
} catch (e) {
26+
if (options.debug) {
27+
throw e;
28+
} else {
29+
console.log("\x1B[31;1m" + e.message + "\x1B[0m");
30+
}
31+
}
32+
}
33+
34+
private getCommandArguments(): string[] {
35+
var remaining = options._;
36+
return remaining.length > 1 ? remaining.slice(1) : [];
37+
}
38+
39+
private getCommandName(): string {
40+
var remaining = options._;
41+
return remaining.length > 0 ? remaining[0].toLowerCase() : "help";
42+
}
43+
}

lib/commands/device-types.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
///<reference path=".././.d.ts"/>
2-
"use strict";
3-
import iphoneSimulatorLibPath = require("./../iphone-simulator");
1+
import { iPhoneSimulator } from "../iphone-simulator";
42

53
export class Command implements ICommand {
6-
public execute(args: string[]): Promise<void> {
7-
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
8-
return iphoneSimulator.printDeviceTypes();
9-
}
4+
public execute(args: string[]): Promise<void> {
5+
var iphoneSimulator = new iPhoneSimulator();
6+
return iphoneSimulator.printDeviceTypes();
7+
}
108
}

lib/commands/help.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
///<reference path=".././.d.ts"/>
2-
"use strict";
3-
4-
import fs = require("fs");
5-
import path = require("path");
6-
import util = require("util");
1+
import * as fs from "fs";
2+
import * as path from "path";
3+
import * as util from "util";
74

85
export class Command implements ICommand {
96
public execute(args: string[]): void {

lib/commands/launch.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import iphoneSimulatorLibPath = require("./../iphone-simulator");
2-
import options = require("../options");
1+
import { iPhoneSimulator } from "../iphone-simulator";
2+
import * as options from "../options";
33

44
export class Command implements ICommand {
5-
public execute(args: string[]): Promise<string> {
6-
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
7-
return iphoneSimulator.run(args[0], args[1], options);
8-
}
9-
}
5+
public execute(args: string[]): Promise<string> {
6+
var iphoneSimulator = new iPhoneSimulator();
7+
return iphoneSimulator.run(args[0], args[1], options);
8+
}
9+
}

lib/commands/notify-post.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import iphoneSimulatorLibPath = require("./../iphone-simulator");
1+
import { iPhoneSimulator } from "./../iphone-simulator";
22

33
export class Command implements ICommand {
4-
public execute(args: string[]): Promise<void> {
5-
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
6-
return iphoneSimulator.sendNotification(args[0], args[1]);
7-
}
8-
}
4+
public execute(args: string[]): Promise<void> {
5+
var iphoneSimulator = new iPhoneSimulator();
6+
return iphoneSimulator.sendNotification(args[0], args[1]);
7+
}
8+
}

lib/commands/sdks.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
///<reference path=".././.d.ts"/>
2-
"use strict";
3-
import iphoneSimulatorLibPath = require("./../iphone-simulator");
1+
import { iPhoneSimulator } from "./../iphone-simulator";
42

53
export class Command implements ICommand {
6-
public execute(args: string[]): Promise<void> {
7-
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
8-
return iphoneSimulator.printSDKS();
9-
}
4+
public execute(args: string[]): Promise<void> {
5+
var iphoneSimulator = new iPhoneSimulator();
6+
return iphoneSimulator.printSDKS();
7+
}
108
}

lib/declarations.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
///<reference path="./.d.ts"/>
2-
"use strict";
3-
4-
51
interface IDictionary<T> {
62
[key: string]: T
73
}

lib/errors.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path="./.d.ts"/>
2-
"use strict";
3-
41
import * as util from "util";
52

63
export function fail(errorMessage: string, ...args: string[]) {

0 commit comments

Comments
 (0)