From 5fcd7e5965631f91adee4fde0148ec0ed820beb0 Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Thu, 31 May 2018 14:59:35 +0300 Subject: [PATCH] Fixed getPkgDir --- src/nimblepkg/nimscriptsupport.nim | 2 +- tests/nimscript/nimscript.nimble | 2 +- tests/tester.nim | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/nimblepkg/nimscriptsupport.nim b/src/nimblepkg/nimscriptsupport.nim index 804f540..c959dc2 100644 --- a/src/nimblepkg/nimscriptsupport.nim +++ b/src/nimblepkg/nimscriptsupport.nim @@ -388,7 +388,7 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym = # Setup builtins defined in nimscriptapi.nim template cbApi(name, body) {.dirty.} = - vm.globalCtx.registerCallback pkgName & "." & astToStr(name), + vm.globalCtx.registerCallback "nimscriptapi." & astToStr(name), proc (a: VmArgs) = body diff --git a/tests/nimscript/nimscript.nimble b/tests/nimscript/nimscript.nimble index d1adfba..5842afd 100644 --- a/tests/nimscript/nimscript.nimble +++ b/tests/nimscript/nimscript.nimble @@ -27,7 +27,7 @@ task repeated, "Testing `nimble c nimscript.nim` with repeated flags": setCommand "c", "nimscript.nim" task api, "Testing nimscriptapi module functionality": - echo(getPkgDir()) + echo("PKG_DIR: ", getPkgDir()) before hooks: echo("First") diff --git a/tests/tester.nim b/tests/tester.nim index acd6bdc..2651d50 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -294,6 +294,13 @@ test "pre hook can prevent action": check(not inLines(lines, "Shouldn't happen")) check inLines(lines, "Hook prevented further execution") +test "nimble script api": + cd "nimscript": + let (output, exitCode) = execNimble("api") + let lines = output.strip.splitLines() + check exitCode == QuitSuccess + check inLines(lines, "PKG_DIR: " & getCurrentDir()) + test "can install packagebin2": let args = ["install", "-y", "https://github.com/nimble-test/packagebin2.git"] check execNimble(args).exitCode == QuitSuccess