File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class FormatFrontend: Frontend {
3939 return
4040 }
4141
42- var stdoutStream = FileHandle . standardOutput
42+ var stdoutStream = FileHandleTextOutputStream ( FileHandle . standardOutput)
4343 do {
4444 if inPlace {
4545 var buffer = " "
Original file line number Diff line number Diff line change 1212
1313import Foundation
1414
15- extension FileHandle : TextOutputStream {
16- public func write( _ string: String ) {
17- self . write ( string. data ( using: . utf8) !) // Conversion to UTF-8 cannot fail
15+ /// Wraps a `FileHandle` so that it can be used by APIs that take a `TextOutputStream`-conforming
16+ /// type as an input.
17+ struct FileHandleTextOutputStream : TextOutputStream {
18+ /// The underlying file handle to which the text will be written.
19+ private var fileHandle : FileHandle
20+
21+ /// Creates a new output stream that writes to the given file handle.
22+ init ( _ fileHandle: FileHandle ) {
23+ self . fileHandle = fileHandle
24+ }
25+
26+ func write( _ string: String ) {
27+ fileHandle. write ( string. data ( using: . utf8) !) // Conversion to UTF-8 cannot fail
1828 }
1929}
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ final class StderrDiagnosticPrinter {
6464 /// Prints a diagnostic to standard error.
6565 func printDiagnostic( _ diagnostic: TSCBasic . Diagnostic ) {
6666 printQueue. sync {
67- let stderr = FileHandle . standardError
67+ let stderr = FileHandleTextOutputStream ( FileHandle . standardError)
6868
6969 stderr. write ( " \( ansiSGR ( . boldWhite) ) \( diagnostic. location) : " )
7070
You can’t perform that action at this time.
0 commit comments