Skip to content

Commit 11c22de

Browse files
committed
Updates TecoPackageGenerator to match model layout changes
1 parent 23a8e3a commit 11c22de

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Sources/TecoPackageGenerator/generator.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import TecoCodeGeneratorCommons
77
@main
88
struct TecoPackageGenerator: ParsableCommand {
99
@Option(name: .shortAndLong, completion: .directory, transform: URL.init(fileURLWithPath:))
10-
var serviceManifestDir: URL
10+
var modelDir: URL
1111

1212
@Option(name: .shortAndLong, completion: .directory, transform: URL.init(fileURLWithPath:))
1313
var packageDir: URL
@@ -21,7 +21,10 @@ struct TecoPackageGenerator: ParsableCommand {
2121
func run() throws {
2222
var targets: [(service: String, version: String)] = []
2323

24-
let serviceDirectories = try FileManager.default.contentsOfDirectory(at: serviceManifestDir, includingPropertiesForKeys: nil)
24+
let serviceDirectories = try FileManager.default.contentsOfDirectory(
25+
at: modelDir.appendingPathComponent("services"),
26+
includingPropertiesForKeys: nil
27+
)
2528

2629
if serviceGenerator != nil {
2730
try FileManager.default.removeItem(at: packageDir.appendingPathComponent("Sources"))
@@ -50,9 +53,14 @@ struct TecoPackageGenerator: ParsableCommand {
5053
process.executableURL = serviceGenerator
5154
process.arguments = [
5255
"--source=\(manifestJSON.path)",
53-
"--error-file=\(serviceManifestDir.deletingLastPathComponent().path)/error-codes.json",
5456
"--output-dir=\(sourceDirectory.path)",
5557
]
58+
59+
let errorFilePath = modelDir.appendingPathComponent("error-codes.json")
60+
if FileManager().isReadableFile(atPath: errorFilePath.path) {
61+
process.arguments?.append("--error-file=\(errorFilePath.path)")
62+
}
63+
5664
process.terminationHandler = { process in
5765
if process.terminationStatus != 0 {
5866
print(process.arguments ?? [], process.terminationReason)

0 commit comments

Comments
 (0)