Improve summary print
This commit is contained in:
parent
225c68ecd1
commit
464ece4a03
@ -3,10 +3,8 @@ import Foundation
|
|||||||
func checkDependencies() -> Bool {
|
func checkDependencies() -> Bool {
|
||||||
print("--- DEPENDENCIES -----------------------------------")
|
print("--- DEPENDENCIES -----------------------------------")
|
||||||
print(" ")
|
print(" ")
|
||||||
let result = checkImageOptimAvailability() && checkMagickAvailability() && checkCwebpAvailability() && checkAvifAvailability()
|
defer { print(" ") }
|
||||||
print(" Complete: \(result ? "Yes" : "No")")
|
return checkImageOptimAvailability() && checkMagickAvailability() && checkCwebpAvailability() && checkAvifAvailability()
|
||||||
print(" ")
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func checkImageOptimAvailability() -> Bool {
|
private func checkImageOptimAvailability() -> Bool {
|
||||||
|
@ -110,8 +110,8 @@ private func copyFiles(files: FileData, configuration: Configuration, runFolder:
|
|||||||
generator.generate()
|
generator.generate()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func finish(start: Date) {
|
private func finish(start: Date, complete: Bool) {
|
||||||
print("----------------------------------------------------")
|
print("--- SUMMARY ----------------------------------------")
|
||||||
print(" ")
|
print(" ")
|
||||||
let duration = Int(-start.timeIntervalSinceNow.rounded())
|
let duration = Int(-start.timeIntervalSinceNow.rounded())
|
||||||
if duration < 60 {
|
if duration < 60 {
|
||||||
@ -121,11 +121,19 @@ private func finish(start: Date) {
|
|||||||
} else {
|
} else {
|
||||||
print(String(format: " Duration: %d:%02d:%02d", duration / 3600, (duration / 60) % 60, duration % 60))
|
print(String(format: " Duration: %d:%02d:%02d", duration / 3600, (duration / 60) % 60, duration % 60))
|
||||||
}
|
}
|
||||||
|
print(" Complete: \(complete ? "Yes" : "No")")
|
||||||
print(" ")
|
print(" ")
|
||||||
|
print("----------------------------------------------------")
|
||||||
}
|
}
|
||||||
|
|
||||||
private func generate(configPath: String) throws {
|
private func generate(configPath: String) throws {
|
||||||
let start = Date()
|
let start = Date()
|
||||||
|
var complete = false
|
||||||
|
|
||||||
|
defer {
|
||||||
|
// 6. Print summary
|
||||||
|
finish(start: start, complete: complete)
|
||||||
|
}
|
||||||
|
|
||||||
print(" ")
|
print(" ")
|
||||||
|
|
||||||
@ -167,6 +175,5 @@ private func generate(configPath: String) throws {
|
|||||||
// 5. Copy/minify files
|
// 5. Copy/minify files
|
||||||
copyFiles(files: files, configuration: configuration, runFolder: runFolder)
|
copyFiles(files: files, configuration: configuration, runFolder: runFolder)
|
||||||
|
|
||||||
// 6. Print summary
|
complete = true
|
||||||
finish(start: start)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user