From 8969aec42f6a7af3e21fc13403ecddf1fe503ab2 Mon Sep 17 00:00:00 2001 From: Andy Davidoff Date: Thu, 28 Nov 2019 13:11:42 -0500 Subject: [PATCH] 0.0.15: global env expansions are okay --- nimph.nimble | 2 +- src/nimph/config.nim | 17 ++++++++++------- src/nimph/doctor.nim | 2 +- src/nimph/project.nim | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/nimph.nimble b/nimph.nimble index 503d1b6..76b078f 100644 --- a/nimph.nimble +++ b/nimph.nimble @@ -1,4 +1,4 @@ -version = "0.0.14" +version = "0.0.15" author = "disruptek" description = "nim package handler from the future" license = "MIT" diff --git a/src/nimph/config.nim b/src/nimph/config.nim index 00af156..5bf6b73 100644 --- a/src/nimph/config.nim +++ b/src/nimph/config.nim @@ -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: @@ -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 @@ -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 @@ -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 diff --git a/src/nimph/doctor.nim b/src/nimph/doctor.nim index 7bd8619..e625538 100644 --- a/src/nimph/doctor.nim +++ b/src/nimph/doctor.nim @@ -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: diff --git a/src/nimph/project.nim b/src/nimph/project.nim index 5f1ce8d..8e357fc 100644 --- a/src/nimph/project.nim +++ b/src/nimph/project.nim @@ -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