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