Skip to content

Commit 79ef1fd

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #43 from telerik/fatme/fix-ios-sim-commands
Execute the command only if the file exists
2 parents 6f91fc4 + 87beb6f commit 79ef1fd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/command-executor.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"use strict";
33

44
import Future = require("fibers/future");
5+
import fs = require("fs");
6+
import path = require("path");
57
import util = require("util");
68
require("colors");
79

@@ -20,12 +22,16 @@ export class CommandExecutor implements ICommandExecutor {
2022
private executeCore(commandName: string, commandArguments: string[]): IFuture<void> {
2123
return (() => {
2224
try {
23-
var command: ICommand = new (require("./commands/" + commandName).Command)();
24-
if(!command) {
25-
errors.fail("Unable to resolve commandName %s", commandName);
25+
let filePath = path.join(__dirname, "commands", commandName + ".js");
26+
if(fs.existsSync(filePath)) {
27+
var command: ICommand = new (require(filePath).Command)();
28+
if(!command) {
29+
errors.fail("Unable to resolve commandName %s", commandName);
30+
}
31+
32+
command.execute(commandArguments).wait();
2633
}
2734

28-
command.execute(commandArguments).wait();
2935
} catch(e) {
3036
if(options.debug) {
3137
throw e;

0 commit comments

Comments
 (0)