Skip to content

Commit

Permalink
1.8.5: subprocess errors emit stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Nov 3, 2019
1 parent 23caa40 commit 96a2d6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions bump.nim
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ proc withCrazySpaces*(version: Version; line = ""): string =

proc capture*(exe: string; args: seq[string]): tuple[output: string; ok: bool] =
## find and run a given executable with the given arguments;
## the result includes stdout and a true value if it seemed to work
## the result includes stdout and a true value if it seemed to work;
## else it includes a mixture of stderr and stdout and a falsey `ok`
var
command = findExe(exe)
if command == "":
Expand All @@ -217,7 +218,8 @@ proc capture*(exe: string; args: seq[string]): tuple[output: string; ok: bool] =
debug command # let's take a look at those juicy escape sequences

# run it and get the output to construct our return value
let (output, exit) = execCmdEx(command, {poEvalCommand, poDaemon})
let (output, exit) = execCmdEx(command, {poStdErrToStdOut, poDaemon,
poEvalCommand})
result = (output: output, ok: exit == 0)

# provide a simplified summary at appropriate logging levels
Expand All @@ -235,19 +237,24 @@ proc run*(exe: string; args: varargs[string]): bool =
arguments: seq[string]
for n in args:
arguments.add n
result = capture(exe, arguments).ok
let
caught = capture(exe, arguments)
if not caught.ok:
notice caught.output
result = caught.ok

proc appearsToBeMasterBranch*(): Option[bool] =
## try to determine if we're on the `master` branch
var
caught = capture("git", @["branch", "--show-current"])
if not caught.ok:
if caught.ok:
result = caught.output.contains(re"(*ANYCRLF)(?m)(?x)^master$").some
else:
caught = capture("git", @["branch"])
if not caught.ok:
notice caught.output
return
result = caught.output.contains(re"(*ANYCRLF)(?m)(?x)^\*\smaster$").some
else:
result = caught.output.contains(re"(*ANYCRLF)(?m)(?x)^master$").some
debug &"appears to be master branch? {result.get}"

proc fetchTagList*(): Option[string] =
Expand All @@ -258,6 +265,7 @@ proc fetchTagList*(): Option[string] =
if not caught.ok:
caught = capture("git", @["tag", "--list"])
if not caught.ok:
notice caught.output
return
result = caught.output.strip.some

Expand Down
2 changes: 1 addition & 1 deletion bump.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.8.4"
version = "1.8.5"
author = "disruptek"
description = "a tiny tool to bump nimble versions"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions docs/bump.html
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ <h1><a class="toc-backref" href="#12">Procs</a></h1>
<span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>

find and run a given executable with the given arguments; the result includes stdout and a true value if it seemed to work
find and run a given executable with the given arguments; the result includes stdout and a true value if it seemed to work; else it includes a mixture of stderr and stdout and a falsey <tt class="docutils literal"><span class="pre">ok</span></tt>

</dd>
<a id="run,string,varargs[string]"></a>
Expand Down Expand Up @@ -1085,7 +1085,7 @@ <h1><a class="toc-backref" href="#12">Procs</a></h1>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small>Made with Nim. Generated: 2019-11-03 03:13:32 UTC</small>
<small>Made with Nim. Generated: 2019-11-03 03:35:47 UTC</small>
</div>
</div>
</div>
Expand Down

0 comments on commit 96a2d6a

Please sign in to comment.