Skip to content

Commit

Permalink
Merge pull request #5 from cobbal/master
Browse files Browse the repository at this point in the history
Removed shell invocation to make quoting easier
  • Loading branch information
davidahouse authored Oct 29, 2019
2 parents a3c5976 + a5eebe1 commit 37d9e84
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Sources/XCResultKit/XCResultFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class XCResultFile {

public func getInvocationRecord() -> ActionsInvocationRecord? {

guard let getOutput = shell(command: ["-l", "-c", "xcrun xcresulttool get --path \(url.path) --format json"]) else {
guard let getOutput = xcrun(["xcresulttool", "get", "--path", url.path, "--format", "json"]) else {
return nil
}

Expand All @@ -42,7 +42,7 @@ public class XCResultFile {

public func getTestPlanRunSummaries(id: String) -> ActionTestPlanRunSummaries? {

guard let getOutput = shell(command: ["-l", "-c", "xcrun xcresulttool get --path \(url.path) --id \(id) --format json"]) else {
guard let getOutput = xcrun(["xcresulttool", "get", "--path", url.path, "--id", id, "--format", "json"]) else {
return nil
}

Expand All @@ -66,7 +66,7 @@ public class XCResultFile {
}

public func getLogs(id: String) -> ActivityLogSection? {
guard let getOutput = shell(command: ["-l", "-c", "xcrun xcresulttool get --path \(url.path) --id \(id) --format json"]) else {
guard let getOutput = xcrun(["xcresulttool", "get", "--path", url.path, "--id", id, "--format", "json"]) else {
return nil
}

Expand All @@ -89,7 +89,7 @@ public class XCResultFile {

public func getActionTestSummary(id: String) -> ActionTestSummary? {

guard let getOutput = shell(command: ["-l", "-c", "xcrun xcresulttool get --path \(url.path) --id \(id) --format json"]) else {
guard let getOutput = xcrun(["xcresulttool", "get", "--path", url.path, "--id", id, "--format", "json"]) else {
return nil
}

Expand All @@ -114,7 +114,7 @@ public class XCResultFile {

public func getPayload(id: String) -> Data? {

guard let getOutput = shell(command: ["-l", "-c", "xcrun xcresulttool get --path \(url.path) --id \(id)"]) else {
guard let getOutput = xcrun(["xcresulttool", "get", "--path", url.path, "--id", id]) else {
return nil
}

Expand All @@ -128,13 +128,13 @@ public class XCResultFile {
public func exportPayload(id: String) -> URL? {

let tempPath = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(id)
_ = shell(command: ["-l", "-c", "xcrun xcresulttool export --type file --path \(url.path) --id \(id) --output-path \(tempPath.path)"])
_ = xcrun(["xcresulttool", "export", "--type", "file", "--path", url.path, "--id", id, "--output-path", tempPath.path])
return tempPath
}

public func getCodeCoverage() -> CodeCoverage? {

guard let getOutput = shell(command: ["-l", "-c", "xcrun xccov view --report --json \(url.path)"]) else {
guard let getOutput = xcrun(["xccov", "view", "--report", "--json", url.path]) else {
return nil
}

Expand All @@ -152,10 +152,10 @@ public class XCResultFile {
}
}

private func shell(command: [String]) -> String? {
private func xcrun(_ arguments: [String]) -> String? {
let task = Process()
task.launchPath = "/bin/sh"
task.arguments = command
task.launchPath = "/usr/bin/xcrun"
task.arguments = arguments

let pipe = Pipe()
task.standardOutput = pipe
Expand Down

0 comments on commit 37d9e84

Please sign in to comment.