fixes #6949
This commit is contained in:
parent
3495c0a46d
commit
0181253eea
1 changed files with 18 additions and 6 deletions
|
|
@ -28,6 +28,10 @@ proc newVersion*(ver: string): Version =
|
||||||
proc isSpecial(ver: Version): bool =
|
proc isSpecial(ver: Version): bool =
|
||||||
return ($ver).len > 0 and ($ver)[0] == '#'
|
return ($ver).len > 0 and ($ver)[0] == '#'
|
||||||
|
|
||||||
|
proc isValidVersion(v: string): bool =
|
||||||
|
if v.len > 0:
|
||||||
|
if v[0] in {'#'} + Digits: return true
|
||||||
|
|
||||||
proc `<`*(ver: Version, ver2: Version): bool =
|
proc `<`*(ver: Version, ver2: Version): bool =
|
||||||
## This is synced from Nimble's version module.
|
## This is synced from Nimble's version module.
|
||||||
|
|
||||||
|
|
@ -72,15 +76,23 @@ proc getPathVersion*(p: string): tuple[name, version: string] =
|
||||||
result.name = p
|
result.name = p
|
||||||
return
|
return
|
||||||
|
|
||||||
|
for i in sepIdx..<p.len:
|
||||||
|
if p[i] in {DirSep, AltSep}:
|
||||||
|
result.name = p
|
||||||
|
return
|
||||||
|
|
||||||
result.name = p[0 .. sepIdx - 1]
|
result.name = p[0 .. sepIdx - 1]
|
||||||
result.version = p.substr(sepIdx + 1)
|
result.version = p.substr(sepIdx + 1)
|
||||||
|
|
||||||
proc addPackage(packages: StringTableRef, p: string) =
|
proc addPackage(packages: StringTableRef, p: string; info: TLineInfo) =
|
||||||
let (name, ver) = getPathVersion(p)
|
let (name, ver) = getPathVersion(p)
|
||||||
|
if isValidVersion(ver):
|
||||||
let version = newVersion(ver)
|
let version = newVersion(ver)
|
||||||
if packages.getOrDefault(name).newVersion < version or
|
if packages.getOrDefault(name).newVersion < version or
|
||||||
(not packages.hasKey(name)):
|
(not packages.hasKey(name)):
|
||||||
packages[name] = $version
|
packages[name] = $version
|
||||||
|
else:
|
||||||
|
localError(info, "invalid package name: " & p)
|
||||||
|
|
||||||
iterator chosen(packages: StringTableRef): string =
|
iterator chosen(packages: StringTableRef): string =
|
||||||
for key, val in pairs(packages):
|
for key, val in pairs(packages):
|
||||||
|
|
@ -109,7 +121,7 @@ proc addPathRec(dir: string, info: TLineInfo) =
|
||||||
if dir[pos] in {DirSep, AltSep}: inc(pos)
|
if dir[pos] in {DirSep, AltSep}: inc(pos)
|
||||||
for k,p in os.walkDir(dir):
|
for k,p in os.walkDir(dir):
|
||||||
if k == pcDir and p[pos] != '.':
|
if k == pcDir and p[pos] != '.':
|
||||||
addPackage(packages, p)
|
addPackage(packages, p, info)
|
||||||
for p in packages.chosen:
|
for p in packages.chosen:
|
||||||
addNimblePath(p, info)
|
addNimblePath(p, info)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue