about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/config.nim18
-rw-r--r--src/main.nim2
2 files changed, 14 insertions, 6 deletions
diff --git a/src/config/config.nim b/src/config/config.nim
index 4869d79c..063c32fc 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -682,7 +682,14 @@ proc parseConfig(config: Config; dir: string; t: TomlValue): ParseConfigResult =
       var includes = config.`include`
       config.`include`.setLen(0)
       for s in includes:
-        let res = config.parseConfig(dir, openFileExpand(dir, s))
+        let fs = openFileExpand(dir, s)
+        if fs == nil:
+          return ParseConfigResult(
+            success: false,
+            warnings: ctx.warnings,
+            errorMsg: "include file not found: " & s
+          )
+        let res = config.parseConfig(dir, fs)
         if not res.success:
           return res
         myRes.warnings.add(res.warnings)
@@ -713,12 +720,13 @@ proc parseConfig*(config: Config; dir, s: string; name = "<input>";
 const defaultConfig = staticRead"res/config.toml"
 
 proc readConfig(config: Config; dir, name: string): ParseConfigResult =
-  let fs = if name.len > 0 and name[0] == '/':
-    newFileStream(name)
+  let path = if name.len > 0 and name[0] == '/':
+    name
   else:
-    newFileStream(dir / name)
+    dir / name
+  let fs = newFileStream(path)
   if fs != nil:
-    return config.parseConfig(dir, fs)
+    return config.parseConfig(parentDir(path), fs)
   return ParseConfigResult(success: true)
 
 proc loadConfig*(config: Config; s: string) {.jsfunc.} =
diff --git a/src/main.nim b/src/main.nim
index f308e1ed..af7ad2a1 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -180,7 +180,7 @@ proc main() =
   var warnings = newSeq[string]()
   let (config, res) = readConfig(ctx.configPath, jsctx)
   if not res.success:
-    stderr.write(res.errorMsg)
+    stderr.writeLine(res.errorMsg)
     quit(1)
   warnings.add(res.warnings)
   for opt in ctx.opts: