fix: inconsistent print of 'config' path in console

Massimo Melina committed Aug 26, 2022 at 16:12 UTC 9c628582b263371484120ef504e0467c4fa10eb6
1 file changed +7 -5
server/src/config.ts
+7 -5
@@ -11,23 +11,25 @@ import { promisify } from 'util'
11 import { join } from 'path'
12 import events from './events'
13
14 -const PATH = 'config.yaml'
14 +const FILE = 'config.yaml'
15
16 -const configProps:Record<string, ConfigProps<any>> = {}
16 +const configProps: Record<string, ConfigProps<any>> = {}
17
18 let started = false // this will tell the difference for subscribeConfig()s that are called before or after config is loaded
19 let state: Record<string, any> = {}
20 const cfgEvents = new EventEmitter()
21 cfgEvents.setMaxListeners(10_000)
22 -const path = with_(argv.config || process.env.HFS_CONFIG || PATH, p => {
22 +const path = with_(argv.config || process.env.HFS_CONFIG, p => {
23 + if (!p)
24 + return FILE
25 try {
26 if (statSync(p).isDirectory()) // try to detect if path points to a folder, in which case we add the standard filename
25 - return join(p, PATH)
27 + return join(p, FILE)
28 }
29 catch {}
28 - console.log("config", p)
30 return p
31 })
32 +console.log("config", path)
33 const { save } = watchLoad(path, values => setConfig(values||{}, false), {
34 failedOnFirstAttempt(){
35 console.log("No config file, using defaults")