Skip to content

Commit

Permalink
Revert "Add backgroundExecuteData for getting raw Data response"
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 authored Sep 8, 2016
1 parent 820642e commit cd5d66d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Sources/Console/Console/Console.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ extension ConsoleProtocol {
)
}

public func backgroundExecuteData(program: String, arguments: [String]) throws -> Data {
public func backgroundExecute(program: String, arguments: [String]) throws -> String {
let input = Pipe()
let output = Pipe()
let error = Pipe()

do {
try execute(
program: program,
Expand All @@ -111,13 +111,9 @@ extension ConsoleProtocol {
let error = String(data: error.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "Unknown"
throw ConsoleError.backgroundExecute(result, error)
}

close(output.fileHandleForWriting.fileDescriptor)
return output.fileHandleForReading.readDataToEndOfFile()
}

public func backgroundExecute(program: String, arguments: [String]) throws -> String {
let data = try backgroundExecuteData(program: program, arguments: arguments)
let data = output.fileHandleForReading.readDataToEndOfFile()
return String(data: data, encoding: .utf8) ?? ""
}
}
Expand Down

0 comments on commit cd5d66d

Please sign in to comment.