Fix #665 - avoid stdout in printPkgInfo
This commit is contained in:
parent
2c87a7fe5e
commit
513780a382
2 changed files with 16 additions and 21 deletions
|
|
@ -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 = ""
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue