Fix config bug
This commit is contained in:
parent
8a5de0acd0
commit
e0e3919d69
@ -35,7 +35,7 @@ extension Config {
|
||||
self.init(loadAt: configFileUrl)
|
||||
} else {
|
||||
self.init(standardIn: directory)
|
||||
|
||||
write(to: configFileUrl)
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,14 +53,15 @@ extension Config {
|
||||
private init(standardIn directory: URL) {
|
||||
let defaultLogPath = directory.appendingPathComponent("logs").path
|
||||
self.init(port: 8000, maxBodySize: "2mb", logPath: defaultLogPath, serveFiles: true, writers: [])
|
||||
|
||||
let configFileUrl = Config.file(in: directory)
|
||||
}
|
||||
|
||||
private func write(to url: URL) {
|
||||
do {
|
||||
let configData = try JSONEncoder().encode(self)
|
||||
try configData.write(to: configFileUrl)
|
||||
print("Default configuration written at \(configFileUrl.path)")
|
||||
try configData.write(to: url)
|
||||
print("Configuration written at \(url.path)")
|
||||
} catch {
|
||||
print("Failed to write default configuration to \(configFileUrl.path)")
|
||||
print("Failed to write default configuration to \(url.path)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user