(no title)
hooch | 4 months ago
Before:
let process = Process()
process.executableURL = URL(fileURLWithPath: "/bin/ls")
let pipe = Pipe()
process.standardOutput = pipe
try! process.run()
process.waitUntilExit()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
if let output = String(data: data, encoding: .utf8) {
print(output)
}
After: let result = try await run(
.name("ls"),
arguments: ["-1"],
output: .string(limit: 1 << 20)
)
print(result.standardOutput ?? "")
fainpul|4 months ago
https://developer.apple.com/documentation/foundation/fileman...