File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -30,15 +30,20 @@ struct MarkdownCommand: ParsableCommand {
30
30
] )
31
31
32
32
static func parseFile( at path: String , options: ParseOptions ) throws -> ( source: String , parsed: Document ) {
33
- let data = try Data ( contentsOf: URL ( fileURLWithPath: path) )
33
+ let data = try Data ( contentsOf: URL ( fileURLWithPath: path) )
34
34
guard let inputString = String ( data: data, encoding: . utf8) else {
35
35
throw Error . couldntDecodeInputAsUTF8
36
36
}
37
37
return ( inputString, Document ( parsing: inputString, options: options) )
38
38
}
39
39
40
40
static func parseStandardInput( options: ParseOptions ) throws -> ( source: String , parsed: Document ) {
41
- let stdinData = FileHandle . standardInput. readDataToEndOfFile ( )
41
+ let stdinData : Data
42
+ if #available( macOS 10 . 15 . 4 , * ) {
43
+ stdinData = try FileHandle . standardInput. readToEnd ( ) ?? Data ( )
44
+ } else {
45
+ stdinData = FileHandle . standardInput. readDataToEndOfFile ( )
46
+ }
42
47
guard let stdinString = String ( data: stdinData, encoding: . utf8) else {
43
48
throw Error . couldntDecodeInputAsUTF8
44
49
}
You can’t perform that action at this time.
0 commit comments