Improve summary print

This commit is contained in:
Christoph Hagen 2022-12-05 11:51:19 +01:00
parent 225c68ecd1
commit 464ece4a03
2 changed files with 14 additions and 9 deletions

View File

@ -3,10 +3,8 @@ import Foundation
func checkDependencies() -> Bool {
print("--- DEPENDENCIES -----------------------------------")
print(" ")
let result = checkImageOptimAvailability() && checkMagickAvailability() && checkCwebpAvailability() && checkAvifAvailability()
print(" Complete: \(result ? "Yes" : "No")")
print(" ")
return result
defer { print(" ") }
return checkImageOptimAvailability() && checkMagickAvailability() && checkCwebpAvailability() && checkAvifAvailability()
}
private func checkImageOptimAvailability() -> Bool {

View File

@ -110,8 +110,8 @@ private func copyFiles(files: FileData, configuration: Configuration, runFolder:
generator.generate()
}
private func finish(start: Date) {
print("----------------------------------------------------")
private func finish(start: Date, complete: Bool) {
print("--- SUMMARY ----------------------------------------")
print(" ")
let duration = Int(-start.timeIntervalSinceNow.rounded())
if duration < 60 {
@ -121,11 +121,19 @@ private func finish(start: Date) {
} else {
print(String(format: " Duration: %d:%02d:%02d", duration / 3600, (duration / 60) % 60, duration % 60))
}
print(" Complete: \(complete ? "Yes" : "No")")
print(" ")
print("----------------------------------------------------")
}
private func generate(configPath: String) throws {
let start = Date()
var complete = false
defer {
// 6. Print summary
finish(start: start, complete: complete)
}
print(" ")
@ -167,6 +175,5 @@ private func generate(configPath: String) throws {
// 5. Copy/minify files
copyFiles(files: files, configuration: configuration, runFolder: runFolder)
// 6. Print summary
finish(start: start)
complete = true
}