Skip to content

Commit

Permalink
No success for missing task
Browse files Browse the repository at this point in the history
  • Loading branch information
genotrance committed Apr 16, 2019
1 parent 8c2e65e commit 74201bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/nimblepkg/nimscriptapi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var

command = "e"
project = ""
success = false
retVal = true

proc requires*(deps: varargs[string]) =
Expand Down Expand Up @@ -112,6 +113,7 @@ proc onExit() =
else:
var
output = ""
output &= "\"success\": " & $success & ", "
output &= "\"command\": \"" & command & "\", "
if project.len != 0:
output &= "\"project\": \"" & project & "\", "
Expand Down Expand Up @@ -140,8 +142,10 @@ template task*(name: untyped; description: string; body: untyped): untyped =
proc `name Task`*() = body
if commandLineParams.len == 0 or "help" in commandLineParams:
success = true
echo(astToStr(name), " ", description)
elif astToStr(name).normalize in commandLineParams:
success = true
`name Task`()
template before*(action: untyped, body: untyped): untyped =
Expand All @@ -153,6 +157,7 @@ template before*(action: untyped, body: untyped): untyped =
beforeHooks.add astToStr(action)
if (astToStr(action) & "Before").normalize in commandLineParams:
success = true
retVal = `action Before`()
template after*(action: untyped, body: untyped): untyped =
Expand All @@ -164,6 +169,7 @@ template after*(action: untyped, body: untyped): untyped =
afterHooks.add astToStr(action)
if (astToStr(action) & "After").normalize in commandLineParams:
success = true
retVal = `action After`()
proc getPkgDir(): string =
Expand Down
3 changes: 2 additions & 1 deletion src/nimblepkg/nimscriptwrapper.nim
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ proc execScript*(scriptName, actionName: string, options: Options): ExecutionRes
else:
parseJson("{}")

result.success = true
result.flags = newTable[string, seq[string]]()
if "success" in j:
result.success = j["success"].getBool()
if "command" in j:
result.command = j["command"].getStr()
else:
Expand Down

0 comments on commit 74201bc

Please sign in to comment.