Skip to content

Commit

Permalink
Fix empty param, json echo
Browse files Browse the repository at this point in the history
  • Loading branch information
genotrance committed Apr 17, 2019
1 parent b22fe37 commit 24131de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/nimblepkg/nimscriptapi.nim
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ proc requires*(deps: varargs[string]) =

proc getParams() =
for i in 5 .. paramCount():
commandLineParams.add paramStr(i).normalize
if paramStr(i).len != 0:
commandLineParams.add paramStr(i).normalize

proc getCommand(): string =
return command
Expand Down
20 changes: 9 additions & 11 deletions src/nimblepkg/nimscriptwrapper.nim
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ const
nimscriptHash = $nimscriptApi.hash().abs()

proc execNimscript(nimsFile, actionName: string, options: Options, live = true): tuple[output: string, exitCode: int] =
if live:
let
cmd = "nim"
args = @["e", "--hints:off", "--verbosity:0", nimsFile, actionName]
var
cmd = ("nim e --hints:off --verbosity:0 " & nimsFile.quoteShell & " " & actionName).strip()

if live:
var
line: string
p = startProcess(cmd, args=args, options={poUsePath, poEchoCmd})
p = startProcess("nim", args=cmd.parseCmdLine()[1 .. ^1], options={poUsePath})
sout = p.outputStream()

try:
Expand All @@ -39,19 +38,18 @@ proc execNimscript(nimsFile, actionName: string, options: Options, live = true):
else:
break

echo line
if line.len > 1 and line[0] == '{' and line[^1] == '}':
result.output = line
else:
echo line
except IOError, OSError:
discard

sout.close()

result.output = line
result.exitCode = p.waitForExit()
else:
let
cmd = "nim e --hints:off --verbosity:0 " & nimsFile.quoteShell & " " & actionName

result = execCmdEx(cmd, options = {poUsePath, poEchoCmd})
result = execCmdEx(cmd, options = {poUsePath})

proc setupNimscript*(scriptName: string, options: Options): tuple[nimsFile, iniFile: string] =
let
Expand Down

0 comments on commit 24131de

Please sign in to comment.