Skip to content

Commit

Permalink
Move output file creation just before writing out generated Swift code
Browse files Browse the repository at this point in the history
  • Loading branch information
mgutski committed Jun 16, 2024
1 parent 9d9c2b6 commit c90ac8e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/swift-confidential/Subcommands/Obfuscate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ extension SwiftConfidential {
let configurationYAML = try Data(contentsOf: configuration)
let configuration = try YAMLDecoder().decode(Configuration.self, from: configurationYAML)

guard fileManager.createFile(atPath: output.path, contents: .none) else {
throw RuntimeError(description: #"Failed to create output file at "\#(output.path)""#)
}

var sourceSpecification = try Parsers.ModelTransform.SourceSpecification()
.parse(configuration)

Expand All @@ -52,6 +48,10 @@ extension SwiftConfidential {
let sourceFileText = try Parsers.CodeGeneration.SourceFile()
.parse(&sourceSpecification)

guard fileManager.createFile(atPath: output.path, contents: .none) else {
throw RuntimeError(description: #"Failed to create output file at "\#(output.path)""#)
}

try sourceFileText.write(to: output)
}
}
Expand Down

0 comments on commit c90ac8e

Please sign in to comment.