From cd5d66d5d829810c71d4fee1994581f1c8722f1f Mon Sep 17 00:00:00 2001 From: Tanner Date: Wed, 7 Sep 2016 21:47:44 -0400 Subject: [PATCH] Revert "Add `backgroundExecuteData` for getting raw `Data` response" --- Sources/Console/Console/Console.swift | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Sources/Console/Console/Console.swift b/Sources/Console/Console/Console.swift index 46131883..344c93be 100644 --- a/Sources/Console/Console/Console.swift +++ b/Sources/Console/Console/Console.swift @@ -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, @@ -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) ?? "" } }