diff --git a/Sources/App/Config.swift b/Sources/App/Config.swift index 61ee309..7ee358f 100644 --- a/Sources/App/Config.swift +++ b/Sources/App/Config.swift @@ -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)") } } }