Skip to content

Commit f95a3e0

Browse files
Stop cleaning up generated directory
1 parent 114aa33 commit f95a3e0

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

Sources/WebIDLToSwift/IDLBuilder.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,13 @@ enum IDLBuilder {
2828
]
2929

3030
static let outDir = "Sources/DOMKit/WebIDL/"
31-
static func writeFile(named name: String, content: String) throws {
31+
static func writeFile(named name: String, content: String) throws -> String {
3232
let path = outDir + name + ".swift"
3333
if FileManager.default.fileExists(atPath: path) {
34-
fatalError("file already exists for \(name)")
35-
} else {
36-
try (preamble + content).write(toFile: path, atomically: true, encoding: .utf8)
37-
}
38-
}
39-
40-
static func cleanOutputFolder() throws {
41-
for file in try FileManager.default.contentsOfDirectory(atPath: outDir) {
42-
try FileManager.default.removeItem(atPath: outDir + file)
34+
try FileManager.default.removeItem(atPath: path)
4335
}
36+
try (preamble + content).write(toFile: path, atomically: true, encoding: .utf8)
37+
return path
4438
}
4539

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

Sources/WebIDLToSwift/main.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ func main() {
77
do {
88
let startTime = Date()
99
let idl = try IDLParser.parseIDL()
10-
print("Removing old files...")
11-
try IDLBuilder.cleanOutputFolder()
1210
var contents: [SwiftSource] = []
1311
print("Generating bindings...")
1412
contents.append(try IDLBuilder.generateIDLBindings(idl: idl))

0 commit comments

Comments
 (0)