mirror of
https://github.com/daylinmorgan/forge.git
synced 2024-11-24 00:40:45 -06:00
fix: ensure nimble file exists before reading
This commit is contained in:
parent
42edeb0726
commit
19919e1dd9
1 changed files with 8 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
import std/[parsecfg, tables, os, strutils, strformat]
|
||||
|
||||
type
|
||||
Config* = object
|
||||
ForgeConfig* = object
|
||||
targets*: OrderedTableRef[string, string]
|
||||
bins*: OrderedTableRef[string, string]
|
||||
outdir*: string
|
||||
|
@ -10,7 +10,7 @@ type
|
|||
version*: string
|
||||
nimble*: bool
|
||||
|
||||
proc `$`*(c: Config): string =
|
||||
proc `$`*(c: ForgeConfig): string =
|
||||
var lines: seq[string] = @[]
|
||||
lines.add "config ="
|
||||
lines.add "| nimble " & $c.nimble
|
||||
|
@ -26,7 +26,8 @@ proc `$`*(c: Config): string =
|
|||
|
||||
lines.join("\n")
|
||||
|
||||
proc loadConfigFile*(f: string, load_targets: bool, load_bins: bool): Config =
|
||||
proc loadConfigFile*(f: string, load_targets: bool,
|
||||
load_bins: bool): ForgeConfig =
|
||||
let
|
||||
dict = loadConfig(f)
|
||||
base = dict.getOrDefault("")
|
||||
|
@ -70,7 +71,7 @@ proc findNimbleFile(): string =
|
|||
proc inferVersion(s: string, nimbleFile: string): string =
|
||||
if s != "": return s
|
||||
|
||||
# TODO: catch io errors?
|
||||
if nimbleFile.fileExists:
|
||||
let nimbleCfg = loadConfig(nimbleFile)
|
||||
return nimbleCfg.getSectionValue("", "version")
|
||||
|
||||
|
@ -94,7 +95,7 @@ proc newConfig*(
|
|||
nimble: bool,
|
||||
configFile: string,
|
||||
noConfig: bool
|
||||
): Config =
|
||||
): ForgeConfig =
|
||||
|
||||
let nimbleFile = findNimbleFile()
|
||||
|
||||
|
|
Loading…
Reference in a new issue