File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -198,8 +198,8 @@ public class SystemUtils {
198198 }
199199
200200 public static func executeCommand(
201- inDirectory directory: String = NSHomeDirectory ( ) ,
202- path: String ,
201+ inDirectory directory: String = NSHomeDirectory ( ) ,
202+ path: String ,
203203 arguments: [ String ]
204204 ) throws -> String ? {
205205 let task = Process ( )
@@ -216,11 +216,21 @@ public class SystemUtils {
216216 task. arguments = arguments
217217 task. standardOutput = pipe
218218 task. currentDirectoryURL = URL ( fileURLWithPath: directory)
219+
220+ var accumulatedOutput = Data ( )
221+ pipe. fileHandleForReading. readabilityHandler = { handle in
222+ let data = handle. availableData
223+ guard data. isEmpty else { // End of file
224+ return accumulatedOutput. append ( data)
225+ }
226+
227+ handle. readabilityHandler = nil // Stop observing
228+ }
219229
220230 try task. run ( )
221231 task. waitUntilExit ( )
222232 let data = pipe. fileHandleForReading. readDataToEndOfFile ( )
223- return String ( data: data, encoding: . utf8)
233+ return String ( data: accumulatedOutput + data, encoding: . utf8)
224234 }
225235
226236 public func appendCommonBinPaths( path: String ) -> String {
You can’t perform that action at this time.
0 commit comments