Read generator configuration from file
This commit is contained in:
parent
81b373fb5a
commit
570cebb5d0
@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
struct Configuration {
|
||||
struct Configuration: Codable {
|
||||
|
||||
let pageImageWidth: Int
|
||||
|
||||
|
@ -1,11 +1,16 @@
|
||||
import Foundation
|
||||
|
||||
|
||||
let configuration = Configuration(
|
||||
pageImageWidth: <#T##Int#>,
|
||||
minifyCSSandJS: <#T##Bool#>,
|
||||
contentPath: <#T##String#>,
|
||||
outputPath: <#T##String#>)
|
||||
let configUrl = URL(fileURLWithPath: "/Users/ch/Projects/MakerSpace/CHGenerator/config.json")
|
||||
|
||||
let configuration: Configuration
|
||||
do {
|
||||
let data = try Data(contentsOf: configUrl)
|
||||
configuration = try JSONDecoder().decode(from: data)
|
||||
} catch {
|
||||
print("Failed to read configuration: \(error)")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let log = ValidationLog()
|
||||
let files = FileSystem(
|
||||
@ -20,8 +25,8 @@ do {
|
||||
let siteGenerator = try SiteGenerator()
|
||||
siteGenerator.generate(site: siteData)
|
||||
} catch {
|
||||
print(error)
|
||||
exit(0)
|
||||
print("Failed to generate website: \(error)")
|
||||
exit(2)
|
||||
}
|
||||
|
||||
files.printGeneratedPages()
|
||||
@ -31,4 +36,5 @@ files.printDraftPages()
|
||||
files.createImages()
|
||||
print("Images generated")
|
||||
files.copyRequiredFiles()
|
||||
files.printExternalFiles()
|
||||
files.writeHashes()
|
||||
|
6
config_example.json
Normal file
6
config_example.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"pageImageWidth" : 748,
|
||||
"minifyCSSandJS" : true,
|
||||
"contentPath" : "/path/to/content/folder",
|
||||
"outputPath" : "/path/to/output/folder")
|
||||
}
|
Loading…
Reference in New Issue
Block a user