Skip to content

Commit 75d9d06

Browse files
authored
Merge pull request #89 from telerik/yosifov/escape-simctl
Escape all arguments passed to the xcrun simctl
2 parents 80f6cb7 + a4d7229 commit 75d9d06

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/child-process.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ export function execSync(command: string, opts?: any): any {
1212
}
1313
}
1414

15+
export function spawnSync(command: string, args: string[], opts?: any): any {
16+
try {
17+
return child_process.spawnSync(command, args, opts);
18+
} catch (err) {
19+
if (opts && opts.skipError) {
20+
return err;
21+
} else {
22+
throw (new Error(`Error ${err.message} while executing ${command}.`));
23+
}
24+
}
25+
}
26+
1527
export function spawn(command: string, args: string[], opts?: any): Promise<string> {
1628
return new Promise<string>((resolve, reject) => {
1729
let capturedOut = "";

lib/simctl.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ export class Simctl implements ISimctl {
117117
}
118118

119119
private simctlExec(command: string, args: string[], opts?: any): any {
120-
let fullCommand = (["xcrun", "simctl", command].concat(args)).join(" ");
121-
return childProcess.execSync(fullCommand, opts).toString().trim();
120+
let result = childProcess.spawnSync("xcrun", ["simctl", command].concat(args), opts);
121+
if(result && result.stdout) {
122+
return result.stdout.toString().trim();
123+
}
124+
return '';
122125
}
123126
}

0 commit comments

Comments
 (0)