Skip to content

Commit 664867b

Browse files
committed
Get Nimble package version
1 parent ed09462 commit 664867b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/utils/version.nim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import macros
2+
from strutils import replace, splitLines, split, contains
3+
from os import `/`
4+
5+
macro nimbleVersion(): void =
6+
let n = staticRead(currentSourcePath().replace("/src/utils/version.nim") / "nmqtt.nimble")
7+
var v: string
8+
for line in n.splitLines:
9+
let l = split(line, " = ")
10+
if l[0].contains("version"):
11+
v = l[1].replace("\"", "")
12+
break
13+
result = parseStmt("const nmqttVersion* = \"" & v & "\"")
14+
15+
nimbleVersion()

0 commit comments

Comments
 (0)