Remove global configuration and improve printing
This commit is contained in:
@ -56,4 +56,13 @@ struct Configuration: Codable {
|
||||
var outputDirectory: URL {
|
||||
.init(fileURLWithPath: outputPath)
|
||||
}
|
||||
|
||||
func printOverview() {
|
||||
print(" Source folder: \(contentDirectory.path)")
|
||||
print(" Output folder: \(outputDirectory.path)")
|
||||
print(" Page width: \(pageImageWidth)")
|
||||
print(" Minify JavaScript: \(minifyCSSandJS)")
|
||||
print(" Minify CSS: \(minifyCSSandJS)")
|
||||
print(" Create markdown files: \(createMdFilesIfMissing)")
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ final class FileSystem {
|
||||
|
||||
private let images: ImageGenerator
|
||||
|
||||
private let configuration: Configuration
|
||||
|
||||
private var tempFile: URL {
|
||||
input.appendingPathComponent(FileSystem.tempFileName)
|
||||
}
|
||||
@ -68,11 +70,12 @@ final class FileSystem {
|
||||
*/
|
||||
private var generatedPages: Set<String> = []
|
||||
|
||||
init(in input: URL, to output: URL) {
|
||||
init(in input: URL, to output: URL, configuration: Configuration) {
|
||||
self.input = input
|
||||
self.output = output
|
||||
self.images = .init(input: input, output: output)
|
||||
self.generatorInfoFolder = input.appendingPathComponent("run")
|
||||
self.configuration = configuration
|
||||
}
|
||||
|
||||
func urlInOutputFolder(_ path: String) -> URL {
|
||||
@ -102,6 +105,10 @@ final class FileSystem {
|
||||
}
|
||||
}
|
||||
|
||||
func contentOfMdFile(atPath path: String, source: String) -> String? {
|
||||
contentOfOptionalFile(atPath: path, source: source, createEmptyFileIfMissing: configuration.createMdFilesIfMissing)
|
||||
}
|
||||
|
||||
func contentOfOptionalFile(atPath path: String, source: String, createEmptyFileIfMissing: Bool = false) -> String? {
|
||||
let url = input.appendingPathComponent(path)
|
||||
guard exists(url) else {
|
||||
@ -148,6 +155,10 @@ final class FileSystem {
|
||||
images.requireMultiVersionImage(source: source, destination: destination, requiredBy: path, width: width, desiredHeight: desiredHeight)
|
||||
}
|
||||
|
||||
func requireFullSizeMultiVersionImage(source: String, destination: String, requiredBy path: String) -> NSSize {
|
||||
images.requireMultiVersionImage(source: source, destination: destination, requiredBy: path, width: configuration.pageImageWidth, desiredHeight: nil)
|
||||
}
|
||||
|
||||
func createImages() {
|
||||
images.createImages()
|
||||
}
|
||||
|
Reference in New Issue
Block a user