diff --git a/src/nimblepkg/nimscriptapi.nim b/src/nimblepkg/nimscriptapi.nim index 0ace797..fffad4d 100644 --- a/src/nimblepkg/nimscriptapi.nim +++ b/src/nimblepkg/nimscriptapi.nim @@ -81,20 +81,19 @@ template `--`*(key: untyped) = template printIfLen(varName) = if varName.len != 0: - iniOut &= astToStr(varName) & ": \"\"\"" & varName & "\"\"\"\n" + result &= astToStr(varName) & ": \"\"\"" & varName & "\"\"\"\n" template printSeqIfLen(varName) = if varName.len != 0: - iniOut &= astToStr(varName) & ": \"" & varName.join(", ") & "\"\n" + result &= astToStr(varName) & ": \"" & varName.join(", ") & "\"\n" -proc printPkgInfo() = +proc printPkgInfo(): string = if backend.len == 0: backend = "c" - var - iniOut = "[Package]\n" + result = "[Package]\n" if packageName.len != 0: - iniOut &= "name: \"" & packageName & "\"\n" + result &= "name: \"" & packageName & "\"\n" printIfLen version printIfLen author printIfLen description @@ -114,14 +113,13 @@ proc printPkgInfo() = printSeqIfLen afterHooks if requiresData.len != 0: - iniOut &= "\n[Deps]\n" - iniOut &= &"requires: \"{requiresData.join(\", \")}\"\n" - - echo iniOut + result &= "\n[Deps]\n" + result &= &"requires: \"{requiresData.join(\", \")}\"\n" proc onExit*() = if "printPkgInfo".normalize in commandLineParams: - printPkgInfo() + if outFile.len != 0: + writeFile(outFile, printPkgInfo()) else: var output = "" diff --git a/src/nimblepkg/nimscriptwrapper.nim b/src/nimblepkg/nimscriptwrapper.nim index 39df926..10cfae8 100644 --- a/src/nimblepkg/nimscriptwrapper.nim +++ b/src/nimblepkg/nimscriptwrapper.nim @@ -21,8 +21,8 @@ const internalCmd = "e" nimscriptApi = staticRead("nimscriptapi.nim") -proc execNimscript(nimsFile, projectDir, actionName: string, options: Options, - live = true): tuple[output: string, exitCode: int] = +proc execNimscript(nimsFile, projectDir, actionName: string, options: Options): + tuple[output: string, exitCode: int] = let nimsFileCopied = projectDir / nimsFile.splitFile().name & "_" & getProcessId() & ".nims" outFile = getNimbleTempDir() & ".out" @@ -46,13 +46,10 @@ proc execNimscript(nimsFile, projectDir, actionName: string, options: Options, displayDebug("Executing " & cmd) - if live: - result.exitCode = execCmd(cmd) - if outFile.fileExists(): - result.output = outFile.readFile() - discard outFile.tryRemoveFile() - else: - result = execCmdEx(cmd, options = {poUsePath, poStdErrToStdOut}) + result.exitCode = execCmd(cmd) + if outFile.fileExists(): + result.output = outFile.readFile() + discard outFile.tryRemoveFile() proc getNimsFile(scriptName: string, options: Options): string = let @@ -103,7 +100,7 @@ proc getIniFile*(scriptName: string, options: Options): string = if not isIniResultCached: let (output, exitCode) = - execNimscript(nimsFile, scriptName.parentDir(), "printPkgInfo", options, live=false) + execNimscript(nimsFile, scriptName.parentDir(), "printPkgInfo", options) if exitCode == 0 and output.len != 0: result.writeFile(output)