diff --git a/pkginfo.nimble b/pkginfo.nimble index 2f1e672..4e9f7ce 100644 --- a/pkginfo.nimble +++ b/pkginfo.nimble @@ -1,6 +1,6 @@ # Package -version = "0.1.3" +version = "0.1.4" author = "George Lemon" description = "A tiny utility package to extract Nimble information from any project" license = "MIT" @@ -10,7 +10,7 @@ srcDir = "src" # Dependencies requires "nim >= 1.6.4" -requires "semver >= 1.1.1" +requires "semver#head" task tests, "Run tests": exec "testament p 'tests/*.nim'" diff --git a/src/pkginfo.nim b/src/pkginfo.nim index d4ca2ff..3ea7ec4 100644 --- a/src/pkginfo.nim +++ b/src/pkginfo.nim @@ -103,7 +103,8 @@ template parsePkg(dep: JsonNode, hasStaticPkgInfo: bool) = elif pkgName in ["nim", "pkginfo"]: continue let pkgNimbleContents = staticExec("nimble dump " & pkgName & " --json" ) nimblePkg = parseJson(pkgNimbleContents) - else: nimblePkg = dep + else: + nimblePkg = dep Package.dependencies[pkgName] = Pkg(pkgType: Dep) Package.dependencies[pkgName].name = nimblePkg["name"].getStr Package.dependencies[pkgName].version = nimblePkg["version"].getStr @@ -234,7 +235,6 @@ proc nimVersion*(): Version {.compileTime.} = proc dumpProject*(): Pkg {.compileTime.} = result = Pkg(pkgType: Main) let localNimble = parseJson(staticExec("nimble dump" & indent(getProjectPath() /../ "", 1) & " --json" )) - echo localNimble for k, v in pairs(localNimble): if k == "name": result.name = v.getStr diff --git a/tests/test1.nim b/tests/test1.nim index 66e242e..31241e3 100644 --- a/tests/test1.nim +++ b/tests/test1.nim @@ -1,32 +1,32 @@ import unittest, pkginfo test "when not requires ": - when not requires "toktok": - static: assert pkg("toktok") == nil + when not requires "toktok": + static: assert pkg("toktok") == nil test "when requires ": - when requires "semver": - static: - assert pkg("semver") != nil + when requires "semver": + static: + assert pkg("semver") != nil test "when requires -- check `version`": - when requires "semver": - static: - assert pkg("semver").getVersion >= v "1.1.1" + when requires "semver": + static: + assert pkg("semver").getVersion > v("1.1.1") test "when requires -- check `license`": - when requires "semver": - static: - assert pkg("semver").getLicense == "BSD3" + when requires "semver": + static: + assert pkg("semver").getLicense == "BSD3" test "check `nimVersion`": - static: - assert nimVersion() == v "1.6.4" + static: + assert nimVersion() == v "1.6.4" test "check `pkg` `version`": - static: - assert pkg().getVersion >= v "0.1.0" + static: + assert pkg().getVersion >= version("0.1.0") test "check `pkg` `license`": - static: - assert pkg().getLicense == "MIT" \ No newline at end of file + static: + assert pkg().getLicense == "MIT" \ No newline at end of file