mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-17 15:47:08 +03:00
add fatalError helper function
This commit is contained in:
parent
0c5bdfbdbe
commit
cbec3ad732
@ -17,7 +17,7 @@ struct Logger {
|
||||
|
||||
// MARK: - Logging
|
||||
|
||||
func fatal(_ message: String) {
|
||||
func error(_ message: String) {
|
||||
print(isColored ? message.red : message)
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,16 @@ let version = "1.4.0"
|
||||
func generate(spec: String, project: String, isQuiet: Bool) {
|
||||
let logger = Logger(isQuiet: isQuiet)
|
||||
|
||||
func fatalError(_ message: String) -> Never {
|
||||
logger.error(message)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let specPath = Path(spec).normalize()
|
||||
let projectPath = Path(project).normalize()
|
||||
|
||||
if !specPath.exists {
|
||||
logger.fatal("No project spec found at \(specPath.absolute())")
|
||||
exit(1)
|
||||
fatalError("No project spec found at \(specPath.absolute())")
|
||||
}
|
||||
|
||||
let spec: ProjectSpec
|
||||
@ -24,11 +28,9 @@ func generate(spec: String, project: String, isQuiet: Bool) {
|
||||
spec = try ProjectSpec(path: specPath)
|
||||
logger.info("📋 Loaded spec:\n \(spec.debugDescription.replacingOccurrences(of: "\n", with: "\n "))")
|
||||
} catch let error as JSONUtilities.DecodingError {
|
||||
logger.fatal("Parsing spec failed: \(error.description)")
|
||||
exit(1)
|
||||
fatalError("Parsing spec failed: \(error.description)")
|
||||
} catch {
|
||||
logger.fatal("Parsing spec failed: \(error.localizedDescription)")
|
||||
exit(1)
|
||||
fatalError("Parsing spec failed: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
do {
|
||||
@ -41,11 +43,9 @@ func generate(spec: String, project: String, isQuiet: Bool) {
|
||||
try project.write(path: projectFile, override: true)
|
||||
logger.success("💾 Saved project to \(projectFile.string)")
|
||||
} catch let error as SpecValidationError {
|
||||
logger.fatal(error.description)
|
||||
exit(1)
|
||||
fatalError(error.description)
|
||||
} catch {
|
||||
logger.fatal("Generation failed: \(error.localizedDescription)")
|
||||
exit(1)
|
||||
fatalError("Generation failed: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user