mirror of
https://github.com/daylinmorgan/forge.git
synced 2024-11-24 00:40:45 -06:00
fix: prevent seg fault by not accessing nonexistent ref
This commit is contained in:
parent
c71d50dc9b
commit
f3ac3d7722
1 changed files with 16 additions and 10 deletions
|
@ -26,20 +26,26 @@ proc `$`*(c: ForgeConfig): string =
|
|||
|
||||
lines.join("\n")
|
||||
|
||||
proc loadConfigFile*(f: string, load_targets: bool,
|
||||
load_bins: bool): ForgeConfig =
|
||||
let
|
||||
dict = loadConfig(f)
|
||||
base = dict.getOrDefault("")
|
||||
proc loadConfigFile*(
|
||||
f: string,
|
||||
load_targets: bool,
|
||||
load_bins: bool
|
||||
): ForgeConfig =
|
||||
|
||||
let dict = loadConfig(f)
|
||||
|
||||
# get the top level flags
|
||||
if dict.hasKey(""):
|
||||
let base = dict[""]
|
||||
result.nimble = base.hasKey("nimble")
|
||||
result.outdir = base.getOrDefault("outdir")
|
||||
result.name = base.getOrDefault("name")
|
||||
result.version = base.getOrDefault("version")
|
||||
result.format = base.getOrDefault("format")
|
||||
|
||||
result.targets = newOrderedTable[string, string]()
|
||||
result.bins = newOrderedTable[string, string]()
|
||||
|
||||
result.nimble = base.hasKey("nimble")
|
||||
result.outdir = base.getOrDefault("outdir")
|
||||
result.name = base.getOrDefault("name")
|
||||
result.version = base.getOrDefault("version")
|
||||
result.format = base.getOrDefault("format")
|
||||
if dict.hasKey("target") and load_targets:
|
||||
result.targets = dict.getOrDefault("target")
|
||||
if dict.hasKey("bin") and load_bins:
|
||||
|
|
Loading…
Reference in a new issue