Skip to content

Commit

Permalink
0.0.15: global env expansions are okay
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Nov 28, 2019
1 parent 997a931 commit 8969aec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion nimph.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.0.14"
version = "0.0.15"
author = "disruptek"
description = "nim package handler from the future"
license = "MIT"
Expand Down
17 changes: 10 additions & 7 deletions src/nimph/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ iterator pathSubsFor(config: ConfigRef; sub: string; conf: string): string =
when NimMajor <= 1 and NimMinor < 1:
# we have to pick the first lazy path because that's what Nimble does
block found:
for search in config.likelyLazy:
for search in config.lazyPaths:
let search = search.string / ""
if search.endsWith(PkgDir & DirSep):
yield search.parentDir / ""
else:
Expand Down Expand Up @@ -377,7 +378,7 @@ proc bestPathSubstitution(config: ConfigRef; path: string; conf: string): string
break found
result = path

proc removeSearchPath*(nimcfg: Target; path: string): bool =
proc removeSearchPath*(config: ConfigRef; nimcfg: Target; path: string): bool =
## try to remove a path from a nim.cfg; true if it was
## successful and false if any error prevented success
let
Expand All @@ -403,12 +404,12 @@ proc removeSearchPath*(nimcfg: Target; path: string): bool =
for key, value in parsed.table.pairs:
if key.toLowerAscii notin ["p", "path", "nimblepath"]:
continue
for sub in cfg.get.pathSubstitutions(path, nimcfg.repo, write = false):
for sub in config.pathSubstitutions(path, nimcfg.repo, write = false):
if sub notin [value, value / ""]:
continue
let
regexp = re("(*ANYCRLF)(?i)(?s)(-{0,2}" & key.escapeRe & "[:=]\"?" &
value.escapeRe & "/?\"?)\\s*")
regexp = re("(*ANYCRLF)(?i)(?s)(-{0,2}" & key.escapeRe &
"[:=]\"?" & value.escapeRe & "/?\"?)\\s*")
swapped = content.replace(regexp, "")
if swapped == content:
continue
Expand All @@ -422,8 +423,10 @@ proc addSearchPath*(config: ConfigRef; nimcfg: Target; path: string): bool =
best = config.bestPathSubstitution(path, $nimcfg.repo)
result = appendConfig(nimcfg, &"""--path="{best}"""")

proc excludeSearchPath*(nimcfg: Target; path: string): bool =
result = appendConfig(nimcfg, &"""--excludePath="{path}"""")
proc excludeSearchPath*(config: ConfigRef; nimcfg: Target; path: string): bool =
let
best = config.bestPathSubstitution(path, $nimcfg.repo)
result = appendConfig(nimcfg, &"""--excludePath="{best}"""")

iterator extantSearchPaths*(config: ConfigRef; least = 0): string =
## yield existing search paths from the configuration as /-terminated strings
Expand Down
2 changes: 1 addition & 1 deletion src/nimph/doctor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ proc doctor*(project: var Project; dry = true): bool =
warn &"unable to remove search path {path}"

# lazy paths that are missing can be explicitly removed/ignored
for path in likelyLazy(project.cfg, project.repo, least = 0):
for path in likelyLazy(project.cfg, least = 0):
if dirExists(path):
continue
if dry:
Expand Down
4 changes: 2 additions & 2 deletions src/nimph/project.nim
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,11 @@ proc findRepositoryUrl*(path: string): Option[Uri] =

proc removeSearchPath*(project: Project; path: string): bool =
## remove a search path from the project's nim.cfg
result = removeSearchPath(project.nimCfg, path)
result = project.cfg.removeSearchPath(project.nimCfg, path)

proc excludeSearchPath*(project: Project; path: string): bool =
## exclude a search path from the project's nim.cfg
result = excludeSearchPath(project.nimCfg, path)
result = project.cfg.excludeSearchPath(project.nimCfg, path)

proc addSearchPath*(project: Project; path: string): bool =
## add a search path to the given project's configuration
Expand Down

0 comments on commit 8969aec

Please sign in to comment.