Skip to content

Commit 2216041

Browse files
Format only Generated.swift
1 parent f95a3e0 commit 2216041

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/WebIDLToSwift/FormatOutputFiles.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import Foundation
22

33
enum SwiftFormatter {
4-
static func run() {
4+
static func run(source: String) {
55
print("Formatting generated Swift files...")
66
let task = Process()
7-
task.standardOutput = FileHandle.standardOutput
87
task.standardError = FileHandle.standardError
9-
task.arguments = ["-c", "swiftformat Sources/DOMKit/WebIDL"]
8+
task.arguments = ["-c", "swiftformat \(source)"]
109
task.launchPath = "/bin/zsh"
1110
task.launch()
1211
task.waitUntilExit()

Sources/WebIDLToSwift/main.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ func main() {
1616
contents.append(try IDLBuilder.generateStrings())
1717
print("Generating union protocols...")
1818
contents.append(try IDLBuilder.generateUnions())
19+
let outputPath = try IDLBuilder.writeFile(
20+
named: "Generated",
21+
content: contents.joined(separator: "\n\n").source)
1922

20-
try IDLBuilder.writeFile(named: "Generated", content: contents.joined(separator: "\n\n").source)
21-
22-
SwiftFormatter.run()
23+
SwiftFormatter.run(source: outputPath)
2324
print("Done in \(Int(Date().timeIntervalSince(startTime) * 1000))ms.")
2425
} catch {
2526
handleDecodingError(error)

0 commit comments

Comments
 (0)