Skip to content

Commit c2bee0a

Browse files
Move hardcoded output path to main.swift
1 parent 780073d commit c2bee0a

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Sources/WebIDLToSwift/IDLBuilder.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ enum IDLBuilder {
2727
"DOMMatrix_or_Float32Array_or_Float64Array",
2828
]
2929

30-
static let outDir = "Sources/DOMKit/"
31-
static func writeFile(named name: String, content: String) throws -> String {
32-
let path = outDir + name + ".swift"
30+
static func writeFile(path: String, content: String) throws {
3331
if FileManager.default.fileExists(atPath: path) {
3432
try FileManager.default.removeItem(atPath: path)
3533
}
3634
try (preamble + content).write(toFile: path, atomically: true, encoding: .utf8)
37-
return path
3835
}
3936

4037
static func generateIDLBindings(idl: [GenericCollection<IDLNode>]) throws -> SwiftSource {

Sources/WebIDLToSwift/main.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ func main() {
77
do {
88
let startTime = Date()
99
let idl = try IDLParser.parseIDL()
10+
let outputPath = "Sources/DOMKit/Generated.swift"
1011
var contents: [SwiftSource] = []
1112
print("Generating bindings...")
1213
contents.append(try IDLBuilder.generateIDLBindings(idl: idl))
@@ -16,8 +17,8 @@ func main() {
1617
contents.append(try IDLBuilder.generateStrings())
1718
print("Generating union protocols...")
1819
contents.append(try IDLBuilder.generateUnions())
19-
let outputPath = try IDLBuilder.writeFile(
20-
named: "Generated",
20+
try IDLBuilder.writeFile(
21+
path: outputPath,
2122
content: contents.joined(separator: "\n\n").source)
2223

2324
SwiftFormatter.run(source: outputPath)

0 commit comments

Comments
 (0)